Improve taken username warning in registration for when request fails (#7621)
This commit is contained in:
parent
68024c156a
commit
1d02e61655
3 changed files with 29 additions and 12 deletions
|
@ -92,7 +92,7 @@ export default function withValidation<T = undefined, D = void>({
|
|||
}
|
||||
|
||||
const data = { value, allowEmpty };
|
||||
const derivedData = deriveData ? await deriveData(data) : undefined;
|
||||
const derivedData: D | undefined = deriveData ? await deriveData.call(this, data) : undefined;
|
||||
|
||||
const results: IResult[] = [];
|
||||
let valid = true;
|
||||
|
@ -106,13 +106,13 @@ export default function withValidation<T = undefined, D = void>({
|
|||
continue;
|
||||
}
|
||||
|
||||
if (rule.skip && rule.skip.call(this, data, derivedData)) {
|
||||
if (rule.skip?.call(this, data, derivedData)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// We're setting `this` to whichever component holds the validation
|
||||
// function. That allows rules to access the state of the component.
|
||||
const ruleValid = await rule.test.call(this, data, derivedData);
|
||||
const ruleValid: boolean = await rule.test.call(this, data, derivedData);
|
||||
valid = valid && ruleValid;
|
||||
if (ruleValid && rule.valid) {
|
||||
// If the rule's result is valid and has text to show for
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue