Skip to content
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

Merged
merged 3 commits into from
Apr 19, 2020
Merged

Conversation

brendoncaulkins
Copy link
Collaborator

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

  • Updated documentation or README.md
  • If adding new feature(s), added and ran unit tests
  • If create new release, bumped version number
  • Ran npm run style:fix for code style enforcement
  • Ran npm run lint:fix for linting
  • Ran npm audit to discover vulnerabilities

@@ -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)]
Copy link
Collaborator Author

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.

Comment on lines +78 to +80
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`
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Owner

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

Comment on lines +78 to +80
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`
Copy link
Owner

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

@duluca duluca merged commit dc74d9e into master Apr 19, 2020
@duluca duluca deleted the use-error-details-in-messages branch April 19, 2020 22:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants