Guides
GuidesExamplesGitterLog In

Validation

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 is the same, though
you can't do asynchornous validation with 1.2.x).

The form controller is bound to what you specify as the form attribute on the formly-form directive. Make sure to
specify a name on any ng-model in your custom templates to ensure that the formControl is added to the options. If
you're using Angular 1.3, the name attribute is interpolateable (you can use {{id}}). If you are stuck on 1.2.x, you
can use the formly-dynamic-name directive where the value is an expression which would return the name (so,
formly-dynamic-name="id"). 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.

You can also specify custom validation in your JSON. See the field called validators for more information on this. If
you wish to leverage this in a custom template, use the formly-custom-validation directive and pass
options.validators to it.