Clone the repo to your computer
git clone https://github.com/huei90/angular-validation.git
Install Grunt and Download dependencies
npm install -g grunt-cli
npm install
Before coding Boot the Environment
grunt dev # developing environment
grunt check # check the code quality
grunt build # build files
Test
# Test it locally
npm test
Karma Test done by Travis-ci
Start coding
open `rule.js`, looking for `var expression` and `var defaultMsg`
Adding a new expression and defaultMsg to extend it
IP validation As the example
// provider.js
var expression = {
required: /.+/gi,
... // add new expression below
ip: /^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/
};
var defaultMsg = {
required: {
error: 'This should be Required!!',
success: 'It\'s Required'
},
... // add new valid message below
ip: {
error: 'This isn\'t ip',
success: 'It\'s IP'
}
};
When you are done, test it on http://localhost:8080
Give me a PR Thanks for it
Who does the exactly same job ?
- https://github.com/kelp404/angular-validator
- https://github.com/nelsonomuto/angular-ui-form-validation
- (Waiting list..)
Note
- More Status angular/angular.js#583 (comment)
- ngForm module ideas https://docs.google.com/document/d/192dCUnoIBQ7-vurvPeS9BElGdxfk0Ddcof2KzDDi1Mc/edit
- form-angular http://www.forms-angular.org/
- Html5 form-validation http://www.sitepoint.com/client-side-form-validation-html5/