{"id":26964441,"url":"https://github.com/nicklayb/simplevalidator","last_synced_at":"2025-09-05T05:37:39.034Z","repository":{"id":57361449,"uuid":"80792251","full_name":"nicklayb/simplevalidator","owner":"nicklayb","description":"Simple validator for your dom inputs","archived":false,"fork":false,"pushed_at":"2017-02-03T03:47:50.000Z","size":6,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-04-03T06:37:29.357Z","etag":null,"topics":[],"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/nicklayb.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-02-03T03:04:26.000Z","updated_at":"2017-02-03T03:40:52.000Z","dependencies_parsed_at":"2022-09-07T20:00:17.812Z","dependency_job_id":null,"html_url":"https://github.com/nicklayb/simplevalidator","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nicklayb%2Fsimplevalidator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nicklayb%2Fsimplevalidator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nicklayb%2Fsimplevalidator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nicklayb%2Fsimplevalidator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nicklayb","download_url":"https://codeload.github.com/nicklayb/simplevalidator/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nicklayb%2Fsimplevalidator/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259279416,"owners_count":22833412,"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":[],"created_at":"2025-04-03T06:31:30.661Z","updated_at":"2025-06-11T14:04:28.738Z","avatar_url":"https://github.com/nicklayb.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SimpleValidator\n###### By Nicolas Boisvert :: nicklay@me.com\n\n### Simple validator for your dom inputs\n\n## How-to\n\nYou first instanciate you `SimpleValidator` object by passing in an object with your rules, what to do when they're valid and what to do when they're not valid. And after all, all you need to do is call the `check()` method on your SimpleValidator object.\n\n```\nconst validator = new SimpleValidator({\n    rules: {\n        name: () =\u003e {\n            return /* Your name validation */;\n        },\n    },\n    valid: () =\u003e {\n        console.log('valid');\n    },\n    notValid: () =\u003e {\n        console.log('notValid');\n    }\n});\n\nvalidator.check();\n```\n\n### Other methods\n\n#### Adding validator\n\nThere is also other methods like `push` or `pushMany` that allow you to add additionnal validators.\n\n```\nvalidator.push('age', function() {\n    return age \u003e 18;\n});\nvalidator.push({\n    age: function() {\n        return age \u003e 18;\n    },\n    /* Other validations */\n});\n```\n\n#### Removing validator\n\nYou can remove a validator within the `removeRule` method or validate the existance of a method with `hasRule`\n\n```\nvalidator.hasRule('age');   //    Return true;\nvalidator.removeRule('age');\nvalidator.hasRule('age');   //    Return false;\n```\n\n## Conclusion\n\nThank you for using, testing and improving it and feel free to contact me for any question.\n\nEnding joke :\n\u003e **Q** : What do computers and air conditioners have in common? **A** : They both become useless when you open windows\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnicklayb%2Fsimplevalidator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnicklayb%2Fsimplevalidator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnicklayb%2Fsimplevalidator/lists"}