-
Notifications
You must be signed in to change notification settings - Fork 135
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use error details in messages #26
Conversation
@@ -200,7 +200,7 @@ export class ProfileComponent extends BaseFormComponent<IUser> | |||
} | |||
|
|||
convertTypeToPhoneType(type: string): PhoneType { | |||
return $enum(PhoneType).asValueOrThrow(type) | |||
return PhoneType[$enum(PhoneType).asKeyOrThrow(type)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The list of types passed into the drop-down are from $enum(PhoneTypes).getKeys()
, so we want to verify the value we get back is a key (asKeyOrThrow
) and then look that up in the enum.
return `${label} must be at least ${errorDetails?.requiredLength ?? 2} characters` | ||
case 'maxlength': | ||
return `${label} can\'t exceed 50 characters` | ||
return `${label} can\'t exceed ${errorDetails?.requiredLength ?? 50} characters` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
??
is the cool new TypeScript nullish operator.
https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-7.html#nullish-coalescing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@brendoncaulkins yup, updated Ch7 with that info
return `${label} must be at least ${errorDetails?.requiredLength ?? 2} characters` | ||
case 'maxlength': | ||
return `${label} can\'t exceed 50 characters` | ||
return `${label} can\'t exceed ${errorDetails?.requiredLength ?? 50} characters` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@brendoncaulkins yup, updated Ch7 with that info
Feature/Change Description
This adds an enhancement to the FormError directive, that utilizes the error Object passed back from the Reactive Forms validators to help construct the Min/Max length error messages.
Developer Checklist
npm run style:fix
for code style enforcementnpm run lint:fix
for lintingnpm audit
to discover vulnerabilities