Skip to content

Commit

Permalink
fixed typo in password and text field validations (keystonejs#7119)
Browse files Browse the repository at this point in the history
* was showing "must be no longer than x.min" not x.max for longer inputs
  • Loading branch information
moselhy authored Dec 25, 2021
1 parent f63210a commit 23351e4
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion packages/keystone/src/fields/types/password/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ export const password =
}
if (validation.length.max !== null && val.length > validation.length.max) {
args.addValidationError(
`${fieldLabel} must be no longer than ${validation.length.min} characters`
`${fieldLabel} must be no longer than ${validation.length.max} characters`
);
}
if (validation.match && !validation.match.regex.test(val)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ function validate(value: Value, validation: Validation, fieldLabel: string): str
return `${fieldLabel} must be at least ${validation.length.min} characters long`;
}
if (validation.length.max !== null && val.length > validation.length.max) {
return `${fieldLabel} must be no longer than ${validation.length.min} characters`;
return `${fieldLabel} must be no longer than ${validation.length.max} characters`;
}
if (validation.match && !validation.match.regex.test(val)) {
return validation.match.explanation;
Expand Down
2 changes: 1 addition & 1 deletion packages/keystone/src/fields/types/text/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ export const text =
}
if (validation?.length?.max !== undefined && val.length > validation.length.max) {
args.addValidationError(
`${fieldLabel} must be no longer than ${validation.length.min} characters`
`${fieldLabel} must be no longer than ${validation.length.max} characters`
);
}
if (validation?.match && !validation.match.regex.test(val)) {
Expand Down
2 changes: 1 addition & 1 deletion packages/keystone/src/fields/types/text/views/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ function validate(value: TextValue, validation: Validation, fieldLabel: string):
}
}
if (validation.length.max !== null && val.length > validation.length.max) {
messages.push(`${fieldLabel} must be no longer than ${validation.length.min} characters`);
messages.push(`${fieldLabel} must be no longer than ${validation.length.max} characters`);
}
if (validation.match && !validation.match.regex.test(val)) {
messages.push(
Expand Down

0 comments on commit 23351e4

Please sign in to comment.