Guides
GuidesExamplesGitterLog In

Validation

egghead.io lesson | custom validators | integration with is.js

You can specify custom validation in your JSON. See the property called validators on your field config in formly-form for more information on this.

Formly uses angular's built-in validation mechanisms. See the angular docs for more information on this. (Note, if you're using Angular 1.3, formly utilizies the new $validators and $asyncValidators pipelines, otherwise, it falls back to good old $parsers. Either way, your API with formly is the same, including asynchornous validation with 1.2.x!!!! <-- this is a big deal).

The form controller is bound to what you specify as the form attribute on the formly-form directive. Formly will add a formControl property to the field, and you can reference that in your template with options.formControl to get access to properties like $invalid or $error. See the bootstrap templates for an example. Note, there's also a shortcut called fc on the formly-field scope so you have access to it in your templates.

🚧

Learn the nuances of /

/

There are some interesting things you should be aware of when dealing with the different forms with angular. See a decently in-depth explination here: http://jsbin.com/mepega/edit?html,output

📘

No built-in validators

Angular does some validation itself depending on an input's type, but angular-formly doesn't actually ship with any pre-defined validators. You will need to define your own.


Sponsor