valdr

A model centric approach to AngularJS form validation
15 people use it
Submitted by: 684943?v=3 philippd

Defining the validation rules on every input field with the default AngularJS validators pollutes the markup with your business rules and makes them pretty hard to maintain. This is especially true for larger applications, where you may have recurring models like persons or addresses in different forms, but require slightly different markup and therefore can't just reuse an existing form via ng-include or a form directive. What's even worse: Usually you already have the validation logic in your back-end, but there is no easy way to share this information with the UI.

valdr solves these issues by extracting the validation constraints from the markup to a JSON structure. You define the constraints per type and field, tell valdr that a form (or just a part of the form) belongs to a certain type and valdr automatically validates the form fields.

comments powered by Disqus
This page was last updated about 3 years ago.