Validation Builder
Built with one purpose - Make Reactive form validation in Angular easier to use.
- Validation Builder
- Getting started
- Combining Validators
- How it works behind the scenes
- Extending validators
Getting started
Take a look at the live demo to play around with the validators
Install the library
npm i ng-form-validator-builder
Start using the validators
You can add validators using the formBuilder to create a form:
const nextWeek: Date = new Date();
nextWeek.setDate(new Date().getDate() + 7);
const form = new FormBuilder().group({
someDate: [new Date(), DateValidator.isBefore(nextWeek),
anotherDate: [new Date(), DateValidator.isBefore(nextWeek, 'With a custom error message'),
clientName: ['', StringValidator.maxLengthAllowed('25', 'Name is too long!')],
email: ['', [
GenericValidator.isRequired('Email is required'),
stringValidator.email('Please provide a valid email address :)')
]
],
age: [0, NumericValidator.greaterThan(18, 'You need to be older than 18!')
});
More examples
See the live demo for informaion on using the validators