Improve taken username warning in registration for when request fails (#7621)

This commit is contained in:
Michael Telatynski 2022-01-25 10:45:41 +00:00 committed by GitHub
parent 68024c156a
commit 1d02e61655
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 29 additions and 12 deletions

View file

@ -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