{"id":22160628,"url":"https://github.com/jpkleemans/angular-validate","last_synced_at":"2025-10-26T05:52:57.585Z","repository":{"id":32254389,"uuid":"35828755","full_name":"jpkleemans/angular-validate","owner":"jpkleemans","description":"Painless form validation for AngularJS. Powered by the jQuery Validation Plugin.","archived":false,"fork":false,"pushed_at":"2020-01-07T11:15:48.000Z","size":26,"stargazers_count":68,"open_issues_count":4,"forks_count":32,"subscribers_count":10,"default_branch":"master","last_synced_at":"2025-06-24T21:12:23.395Z","etag":null,"topics":["angular","angularjs","validate","validation"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jpkleemans.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-05-18T16:19:09.000Z","updated_at":"2024-03-04T15:47:30.000Z","dependencies_parsed_at":"2022-09-11T02:01:39.285Z","dependency_job_id":null,"html_url":"https://github.com/jpkleemans/angular-validate","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/jpkleemans/angular-validate","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jpkleemans%2Fangular-validate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jpkleemans%2Fangular-validate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jpkleemans%2Fangular-validate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jpkleemans%2Fangular-validate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jpkleemans","download_url":"https://codeload.github.com/jpkleemans/angular-validate/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jpkleemans%2Fangular-validate/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267145524,"owners_count":24042650,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-26T02:00:08.937Z","response_time":62,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["angular","angularjs","validate","validation"],"created_at":"2024-12-02T04:09:05.214Z","updated_at":"2025-10-26T05:52:52.565Z","avatar_url":"https://github.com/jpkleemans.png","language":"JavaScript","readme":"# Angular Validate\n\n[![Bower](https://img.shields.io/bower/v/jpkleemans-angular-validate.svg)](https://github.com/jpkleemans/angular-validate/releases/latest)\n[![GitHub license](https://img.shields.io/github/license/jpkleemans/angular-validate.svg)](https://github.com/jpkleemans/angular-validate/blob/master/LICENSE.md)\n\nPainless form validation for [AngularJS](https://github.com/angular/angular.js). Powered by the [jQuery Validation Plugin](https://github.com/jzaefferer/jquery-validation).\n\n\u003ca href=\"http://jsfiddle.net/fdnh3s4L/25/\" target=\"_blank\"\u003eDEMO\u003c/a\u003e\n\n## Table of contents\n\n1. [Installation](#installation)\n2. [Usage](#usage)\n3. [Built-in validation rules](#built-in-validation-rules)\n4. [Configuration](#configuration)\n\n## Installation\n\nDownload Angular Validate:\n\n\n- With NPM:\n\n```sh\n$ npm install jpkleemans-angular-validate\n```\n\n- With Bower:\n\n```sh\n$ bower install jpkleemans-angular-validate\n```\n\n- With Git:\n\n```sh\n$ git clone https://github.com/jpkleemans/angular-validate.git\n```\n\n- By manually downloading the [latest release](https://github.com/jpkleemans/angular-validate/releases/latest).\n\n\u003e When using one of the last two methods make sure you also download the latest release of the [jQuery Validation Plugin](https://github.com/jzaefferer/jquery-validation).\n\nInclude both `jquery.validate.min.js` and `angular-validate.min.js` in your HTML page:\n\n```html\n\u003c!-- jQuery scripts --\u003e\n\u003cscript src=\"path/to/jquery.min.js\"\u003e\u003c/script\u003e\n\u003cscript src=\"path/to/jquery.validate.min.js\"\u003e\u003c/script\u003e\n\n\u003c!-- Angular scripts --\u003e\n\u003cscript src=\"path/to/angular.min.js\"\u003e\u003c/script\u003e\n\u003cscript src=\"path/to/angular-validate.min.js\"\u003e\u003c/script\u003e\n```\n\nInject the `ngValidate` module as a dependency into your Angular application:\n\n```js\nangular.module('myApp', ['ngValidate']);\n```\n\n## Usage\n\nAdd the ng-validate directive to your form and pass the validation options as value:\n\n```html\n\u003cform name=\"registerform\" ng-submit=\"register(registerform)\" ng-validate=\"validationOptions\"\u003e\n    \u003cinput type=\"email\" name=\"email\"\u003e\n    \u003cinput type=\"password\" name=\"password\"\u003e\n\u003c/form\u003e\n```\n\n#### Set validation options\n\nThen set the validation options in your controller:\n\n```js\n$scope.validationOptions = {\n    rules: {\n        email: {\n            required: true,\n            email: true\n        },\n        password: {\n            required: true,\n            minlength: 6\n        }\n    },\n    messages: {\n        email: {\n            required: \"We need your email address to contact you\",\n            email: \"Your email address must be in the format of name@domain.com\"\n        },\n        password: {\n            required: \"You must enter a password\",\n            minlength: \"Your password must have a minimum length of 6 characters\"\n        }\n    }\n}\n```\n\nOr (for simple forms) insert the options directly without using a controller:\n\n```html\n\u003cform name=\"simpleform\" ng-submit=\"register(simpleform)\" ng-validate=\"{rules: {name: \"required\"}}\"\u003e\n```\n\n\u003e For all available options, see: http://jqueryvalidation.org/validate#validate-options\n\n#### Check form validity\n\nNow you can validate the form by calling `validate()` on the [form instance](https://docs.angularjs.org/guide/forms):\n\n```js\n$scope.register = function (form) {\n    if(form.validate()) {\n        // Form is valid!\n    }\n}\n```\n\n\u003e You can also pass your validation options as the first parameter of `validate()`.\n\n#### Get number of invalid fields\n\n```js\n$window.alert(\"There are \" + form.numberOfInvalids() + \" invalid fields.\");\n```\n\n## Built-in validation rules\n\nA set of standard validation rules is provided by the jQuery Validation Plugin:\n\n- [required](http://jqueryvalidation.org/required-method) – Makes the element required.\n- [remote](http://jqueryvalidation.org/remote-method) – Requests a resource to check the element for validity.\n- [minlength](http://jqueryvalidation.org/minlength-method) – Makes the element require a given minimum length.\n- [maxlength](http://jqueryvalidation.org/maxlength-method) – Makes the element require a given maxmimum length.\n- [rangelength](http://jqueryvalidation.org/rangelength-method) – Makes the element require a given value range.\n- [min](http://jqueryvalidation.org/min-method) – Makes the element require a given minimum.\n- [max](http://jqueryvalidation.org/max-method) – Makes the element require a given maximum.\n- [range](http://jqueryvalidation.org/range-method) – Makes the element require a given value range.\n- [email](http://jqueryvalidation.org/email-method) – Makes the element require a valid email.\n- [url](http://jqueryvalidation.org/url-method) – Makes the element require a valid url.\n- [date](http://jqueryvalidation.org/date-method) – Makes the element require a date.\n- [dateISO](http://jqueryvalidation.org/dateISO-method) – Makes the element require an ISO date.\n- [number](http://jqueryvalidation.org/number-method) – Makes the element require a decimal number.\n- [digits](http://jqueryvalidation.org/digits-method) – Makes the element require digits only.\n- [creditcard](http://jqueryvalidation.org/creditcard-method) – Makes the element require a credit card number.\n- [equalTo](http://jqueryvalidation.org/equalTo-method) – Requires the element to be the same as another one.\n\n\u003e More info: http://jqueryvalidation.org/documentation/#link-list-of-built-in-validation-methods\n\n## Configuration\n\nAngular Validate ships with a $validatorProvider, that you can use to configure default validation options and custom validation rules. \n\n#### Default validation options\n\n```js\nangular.module('myApp')\n    .config(function ($validatorProvider) {\n        $validatorProvider.setDefaults({\n            errorElement: 'span',\n            errorClass: 'help-block'\n        });\n    });\n```\n\n\u003e More info: http://jqueryvalidation.org/jQuery.validator.setDefaults\n\n#### Custom validation rules\n\n```js\nangular.module('myApp')\n    .config(function ($validatorProvider) {\n        $validatorProvider.addMethod(\"domain\", function (value, element) {\n            return this.optional(element) || /^http:\\/\\/mydomain.com/.test(value);\n        }, \"Please specify the correct domain for your documents\");\n    });\n```\n\n\u003e More info: http://jqueryvalidation.org/jQuery.validator.addMethod\n\n#### Modify default error messages\n\n```js\nangular.module('myApp')\n    .config(function ($validatorProvider) {\n        $validatorProvider.setDefaultMessages({\n            required: \"This field is required.\",\n            remote: \"Please fix this field.\",\n            email: \"Please enter a valid email address.\",\n            url: \"Please enter a valid URL.\",\n            date: \"Please enter a valid date.\",\n            dateISO: \"Please enter a valid date (ISO).\",\n            number: \"Please enter a valid number.\",\n            digits: \"Please enter only digits.\",\n            creditcard: \"Please enter a valid credit card number.\",\n            equalTo: \"Please enter the same value again.\",\n            accept: \"Please enter a value with a valid extension.\",\n            maxlength: $validatorProvider.format(\"Please enter no more than {0} characters.\"),\n            minlength: $validatorProvider.format(\"Please enter at least {0} characters.\"),\n            rangelength: $validatorProvider.format(\"Please enter a value between {0} and {1} characters long.\"),\n            range: $validatorProvider.format(\"Please enter a value between {0} and {1}.\"),\n            max: $validatorProvider.format(\"Please enter a value less than or equal to {0}.\"),\n            min: $validatorProvider.format(\"Please enter a value greater than or equal to {0}.\")\n        });\n    });\n```\n\n\u003e More info: http://jqueryvalidation.org/jQuery.validator.format\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjpkleemans%2Fangular-validate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjpkleemans%2Fangular-validate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjpkleemans%2Fangular-validate/lists"}