ng-data-annotation v1.0.4
Online demo
Installation
- Step 1: Use command:
npm install ng-data-annotation --save. - Step 2: Import
ng-data-annotation.min.jsfrom node_modules in application. - Step 3: Start using application.
Properties list
text-property-comparesDescription: * Compare 2 text input properties.
Parameters: -
text-property-compares-operator (char): Comparision mode between 2 properties. Operators can be used:<,<=,=,>=,>,==. The comparision base on the result ofindexOfmethod in javascript. -text-property-compares (string): Specific parameter which needs to be compared with the source element.Validation usage: -
<li ng-message="textPropertyCompares">{{The message can be defined here}}</li>: CatchtextPropertyComparesto display validation message of this custom validation attribute.
numeric-property-comparesDescription: * Compare 2 numeric input properties.
Parameters:
numeric-property-compares-mathematic-operator (char): Specify comparision mathematical operator add/subtract/divide/multiply a range number after that a comparision is done to compare result to target property. Mathematical operators can be used:+,-, `,/. *numeric-property-compares-operator (char): Comparision mode which 2 properties comparision should be done. Comparision operators can be used:<,<=,=,>=,>,==,!=. *numeric-property-compares-mathematic-range (numeric)`: Value which should be added, subtracted, multiplied, divided by the source element value.Validation usage: *
<li ng-message="numericPropertyCompares">{{Validation message can be defined here.}}</li>: CatchnumericPropertyComparesto display validation message.
text-property-containsDescription: * Compare 2 text input properties.
Parameters:
text-property-contains (string): Specify property which needs to be compared.text-property-contains-case-insensitive (bool): Whether case-sensitive should be noticed or not.text-property-contains-result (numeric): Index of property value in source element.text-property-contains-operator (string): Comparision mode between 2 properties. Operators can be used:<,<=,==,>=,>,!=.Validation usage: -
<li ng-message="textPropertyContains">{{Validation message can be defined here}}</li>: CatchtextPropertyContainsto display validation message of this custom validation attribute.
ng-function-validateDescription: * If no validator attributes defined above statisfies your need. This validator can do whatever you want.
Parameters:
ng-function-validate: Specify list of validators. Validators are separated by;character. For example:ng-function-validate="is-adult;is-even;in-out-same".ng-function-validate-monitors: Specify list of parameters which are monitors their changes. When a parameter in the registered list changed, source element will be re-validated. `ng-function-validate-:is in the list defined insideng-function-validate-monitors. Attribute behaviours is operation is the same asnumeric-property-compares,text-property-compares`, ... . For example: * Ifng-function-validate="is-adult;is-even", there should be 2 properties in source element:ng-function-validate-is-adult,ng-function-validate-is-even.Validation usage: `<li ng-message="ng-function-validate-">{{Base on the properties defined in ng-function-validate to display validation message}}`
* For example: * `<li ng-message="ng-function-validate-is-adult">Is not adult</li>` * `<li ng-message="ng-function-validate-is-even">Age must be an even number</li>` * `<li ng-message="ng-function-validate-in-out-same">In out must be the same as each other.</li>`
History
2017, March 20: Initial commit
Credits
- Linh Nguyen