{"id":20819968,"url":"https://github.com/elo7/validate-amd","last_synced_at":"2026-05-21T13:03:50.422Z","repository":{"id":27137147,"uuid":"112524994","full_name":"elo7/validate-amd","owner":"elo7","description":"Validate-amd is a small library to help form validation","archived":false,"fork":false,"pushed_at":"2022-12-30T20:20:06.000Z","size":314,"stargazers_count":1,"open_issues_count":22,"forks_count":0,"subscribers_count":73,"default_branch":"master","last_synced_at":"2025-01-18T16:29:09.096Z","etag":null,"topics":["form","front-end","javascript","lib","martell","nymeros","validation"],"latest_commit_sha":null,"homepage":"","language":"HTML","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/elo7.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-11-29T20:34:55.000Z","updated_at":"2020-07-02T21:28:38.000Z","dependencies_parsed_at":"2023-01-14T06:04:08.806Z","dependency_job_id":null,"html_url":"https://github.com/elo7/validate-amd","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elo7%2Fvalidate-amd","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elo7%2Fvalidate-amd/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elo7%2Fvalidate-amd/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elo7%2Fvalidate-amd/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/elo7","download_url":"https://codeload.github.com/elo7/validate-amd/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243165909,"owners_count":20246809,"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","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":["form","front-end","javascript","lib","martell","nymeros","validation"],"created_at":"2024-11-17T22:07:57.014Z","updated_at":"2025-12-25T13:54:45.242Z","avatar_url":"https://github.com/elo7.png","language":"HTML","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Validate-amd\n\n_Validate-amd library_\n\nvalidate.js is a small library to help form validation. This library uses [amd](http://en.wikipedia.org/wiki/Asynchronous_module_definition) structure.\n\n[![Build Status](https://travis-ci.org/elo7/validate-amd.svg?branch=master)](https://travis-ci.org/elo7/validate-amd)\n\nIt uses html5 form attributes validate specification and works on browsers that does not support html5 validation.\nThen, we built it from scratch.\n\n## Installation\n\n`npm install elo7-validate-amd`\n\n## Dependencies\n\nValidate-amd depends on an [amd](http://en.wikipedia.org/wiki/Asynchronous_module_definition) implementation. We suggest [async-define](https://gist.github.com/sergiolopes/5778124) implementation for dependency lookup.\nValidate-amd also depends on [doc-amd](https://github.com/elo7/doc-amd).\n\n## Methods\n\n#### validateForm\n`.validateForm(selectorOrDocElement)`\n\n###### Description:\nValidate the form using almost all the html5 attributes validate spec. Returns a array with the error messages.\n\n###### Parameters:\n\u003e selectorOrDocElement: doc-amd object or String //A CSS selector. Note that, if it is a class name with dots, the dots must be escaped. E.g.: doc(\".my\\\\\\\\.class\")\n\n###### Sample:\n``` js\ndefine(['validate'], function(Validate) {\n  var validate = new Validate(),\n      errors = validate.validateForm('#form');\n\n  errors.forEach(function(error) {\n    if (error.message) {\n      // executes when there are errors\n    }\n  });\n});\n```\n\n#### validateField\n`.validateField(selectorOrElements)`\n\n###### Description:\nValidate individual fields. Returns an object with a error message.\n\n###### Parameters:\n\u003e selectorOrDocElement: doc-amd object or String //A CSS selector. Note that, if it is a class name with dots, the dots must be escaped. E.g.: doc(\".my\\\\\\\\.class\")\n\n###### Sample:\n``` js\ndefine(['validate'], function(Validate) {\n  var validate = new Validate(),\n      error = validate.validateField($('input[name=example1]'));\n\n  if (error.message) {\n    // executes when there are errors\n  }\n});\n```\n\n### Customize messages\n`new Validate({ messages: object });`\n\n###### Description:\nCustomize the error messages\n\n###### Parameters:\n\u003e object: Object //An object with the properties messages (\"required\", \"min\", \"max\", \"maxlength\", \"pattern\", \"email\" or \"url\")\n\n###### Sample:\n``` js\ndefine(['validate'], function(Validate) {\n   var custom_messages = {\n      'required': 'Field required.',\n      'min': 'Enter a value greater than or equal to {0}.',\n      'max': 'Enter a value greater than or equal to {0}.',\n      'maxlength': 'Enter a value with max length less than or equal to {0}.',\n      'pattern': 'Enter a valid value.',\n      'email': 'Enter a valid email address.',\n      'url': 'Enter a valid url'\n  }\n\n  var validate = new Validate({ messages: custom_messages }),\n      errors = validate.validateForm('#form');\n\n      errors.forEach(function(error) {\n        if (error.message) {\n         // executes when there are errors\n        }\n      });\n});\n```\n\n###### Default messages:\n``` txt\n required: This field is required'\n min: 'Please enter a value greater than or equal to {0}'\n max: 'Please enter a value greater than or equal to {0}'\n maxlength: 'Please enter a value with max length less than or equal to {0}'\n pattern: 'Please enter a valid value'\n email: 'Please enter a valid email address'\n url: 'Please enter a valid url'\n```\n\n## License\n\nValidate-amd is released under the [BSD](https://github.com/elo7/validate-amd/blob/master/LICENSE). Have at it.\n\n* * *\n\nCopyright :copyright: 2017 Elo7# validate-amd","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felo7%2Fvalidate-amd","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Felo7%2Fvalidate-amd","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felo7%2Fvalidate-amd/lists"}