From 02497e8a3386e33e66513db9cbc83634f3134429 Mon Sep 17 00:00:00 2001 From: Pawel Kozlowski Date: Sat, 11 Aug 2012 16:00:09 +0200 Subject: [PATCH] Adding secrion for the ui-validate directive --- index.html | 43 +++++++++++++++++++++++++++++++++++++++++++ js/app.js | 13 +++++++++++++ 2 files changed, 56 insertions(+) diff --git a/index.html b/index.html index b465571..1490da4 100644 --- a/index.html +++ b/index.html @@ -53,6 +53,7 @@
  • Keypress
  • Mask
  • If
  • +
  • Validate
  • Reset
  • Animate
  • Modal
  • @@ -456,6 +457,48 @@

    How?

    +
    + +
    +
    +

    What?

    +

    The ui-validate directive makes it very easy to use any function as a validation function for input elements (using ngModel).

    +
    +
    + + + + This e-mail is black-listed! + + + Both e-mail adresses must match +
    + is form valid: {{form.$valid}}
    + email errors: {{form.email.$error | json}}
    + emailRepeat errors: {{form.emailRepeat.$error | json}} +
    +
    +
    +
    +

    How?

    +

    Just add the 'ui-validate' directive to your input field.

    +

    2 types of syntax are supported: +

      +
    • ui-validate="myValidatorFunction"
    • +
    • ui-validate="{foo : validateFoo, bar : validateBar}"

    • +
    +
    +<input ng-model="email" ui-validate='{blacklist : notBlackListed}'>
    +<span ng-show='form.email.$error.blacklist'>This e-mail is black-listed!</span>
    +
    +

    Why?

    +

    Angular.js comes with several built-in validation mechanism for input fields (ngRequired, ngPattern etc.) but using an arbitrary validation function requires creation of a custom formatters and / or parsers. The ui-validate directive makes it easy to use any function(s) defined in scope as a validator function(s).

    +
    +
    +
    +