ngx-validation-framework
A policy based fluid model validation framework for Angular projects.
Demo
https://ngx-model-validator.web.app/simple
Installation
npm i ngx-model-validator --save
Usage
- Simple validation with error display on field
import NgxValidationModule
in app.module.ts
;;;; ;
// policy ; // component;; public PERSON_POLICY_NAME = 'simple-person-validation';public PERSON_VALIDATION_FN = PersonValidationPolicy; constructorprivate valRunnerSvc: NgxValidationRunnerService validate
- Simple validation without error display on field, errors to be handled in component
// policyvalidatorHelper.validateFor'firstName'.isRequired'First Name is required', // componentthis.valRunnerSvc.validatethis.PERSON_POLICY_NAME, this.person.subscribe;
- Simple validation with required * and error display on field
// policyvalidatorHelper.validateFor'firstName'.isRequired'First Name is required', // componentthis.valRunnerSvc.validatethis.PERSON_POLICY_NAME, this.person
Development server
Run npm run start
for a dev server. Navigate to http://localhost:4200/
. The app will automatically reload if you change any of the source files.
Running unit tests
Run ng test
to execute the unit tests via Karma.