Advanced form validation with AngularJS and filters

PDF

Here’s a neat little trick I discovered that let’s you do wildcard expression checks for an input value:

Wildcard expression validation that marks input valid / invalid

The form in this example ensures that registered persons must be unique by their name:

And the directive that makes this possible:

jsFiddle working example

It’s similar to ui-validate, but you don’t need a scope specific validation function (this works generically) and ofcourse you don’t need angular-ui-utils this way.

In fact, it’s easy to add support for custom validation names and multiple expressions:

jsFiddle working example

Tags:

Leave a Reply