{"id":20509664,"url":"https://github.com/aminnairi/validator","last_synced_at":"2026-04-27T18:03:04.933Z","repository":{"id":56244549,"uuid":"309358852","full_name":"aminnairi/validator","owner":"aminnairi","description":"JavaScript library to validate an object of values based on a set of given rules.","archived":false,"fork":false,"pushed_at":"2020-11-18T19:35:28.000Z","size":127,"stargazers_count":1,"open_issues_count":2,"forks_count":0,"subscribers_count":2,"default_branch":"latest","last_synced_at":"2025-06-25T17:09:40.057Z","etag":null,"topics":["javascript","node","nodejs","rule","rules","validation","validator"],"latest_commit_sha":null,"homepage":"","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/aminnairi.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-11-02T12:08:23.000Z","updated_at":"2020-11-18T11:06:18.000Z","dependencies_parsed_at":"2022-08-15T15:20:37.979Z","dependency_job_id":null,"html_url":"https://github.com/aminnairi/validator","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/aminnairi/validator","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aminnairi%2Fvalidator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aminnairi%2Fvalidator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aminnairi%2Fvalidator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aminnairi%2Fvalidator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aminnairi","download_url":"https://codeload.github.com/aminnairi/validator/tar.gz/refs/heads/latest","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aminnairi%2Fvalidator/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32348058,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-27T17:12:42.749Z","status":"ssl_error","status_checked_at":"2026-04-27T17:12:41.658Z","response_time":128,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["javascript","node","nodejs","rule","rules","validation","validator"],"created_at":"2024-11-15T20:25:56.026Z","updated_at":"2026-04-27T18:03:04.916Z","avatar_url":"https://github.com/aminnairi.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# validator\n\n![Tests](https://github.com/aminnairi/validator/workflows/Tests/badge.svg?branch=latest) ![Code Style](https://github.com/aminnairi/validator/workflows/Code%20Style/badge.svg?branch=latest)\n\nJavaScript library to validate an object of values based on a set of given rules.\n\n*:warning: This library is still in its early stage. Usage is permitted but without any guarantees the API will not change in a near future.*\n\n```javascript\n\"use strict\";\n\nconst {Validator} = require(\"@aminnairi/validator\");\n\nnew Validator({secret: \"required|string|password\"}).validate({secret: \"kitten123\"});\n```\n\n## Requirements\n\n- [Git](https://git-scm.com/)\n- [NPM](https://www.npmjs.com/)\n\n## Installation\n\n```console\n$ npm install aminnairi/validator\n```\n\n## Uninstallation\n\n```console\n$ npm uninstall @aminnairi/validator\n```\n\n## API\n\n### Constructor\n\n#### Synopsis\n\nInstanciate a new validator.\n\n#### Prototype\n\n```typescript\nnew: (rules: Record\u003cstring, string\u003e) =\u003e Validator;\n```\n\n### setTranslations\n\n#### Synopsis\n\nCustomize the error messages generated by the validator.\n\n#### Prototype\n\n```typescript\nsetTranslations: (translations: Record\u003cstring, Record\u003cstring, string\u003e\u003e) =\u003e void;\n```\n\n### validate\n\n#### Synopsis\n\nReturn properties that do not match the rules set for the created validator.\n\n#### Prototype\n\n```typescript\nvalidate: (data: Record\u003cstring, any\u003e) =\u003e null | Record\u003cstring, string[]\u003e;\n```\n\n## Rules\n\n### Date\n\n#### Synopsis\n\nCheck if the value is a date.\n\n#### Example\n\nSee [`example/date.js`](./examples/date.js).\n\n### Different\n\n#### Synopsis\n\nCheck if the value is not equal to another.\n\n#### Example\n\nSee [`example/different.js`](./examples/different.js).\n\n### Email\n\n#### Synopsis\n\nCheck if the value is a valid email.\n\n#### Example\n\nSee [`example/email.js`](./examples/email.js).\n\n### In\n\n#### Synopsis\n\nCheck if the value is include inside a set of values.\n\n#### Example\n\nSee [`example/in.js`](./examples/in.js).\n\n### Integer\n\n#### Synopsis\n\nCheck if the value is an integer.\n\n#### Example\n\nSee [`example/integer.js`](./examples/integer.js).\n\n### Maximum\n\n#### Synopsis\n\nCheck if a number is lower or equal to a given one. This also checks if a string has a length of at most a given length.\n\n#### Example\n\nSee [`example/maximum.js`](./examples/maximum.js).\n\n### Minimum\n\n#### Synopsis\n\nCheck if a number is greater or equal to given one. This also checks if a string has a length of at least a given length.\n\n#### Example\n\nSee [`example/minimum.js`](./examples/minimum.js).\n\n### Password\n\n#### Synopsis\n\nCheck if a value has at least one lower and uppercase letter, one digit, one symbol and at least 8 characters.\n\n#### Example\n\nSee [`example/password.js`](./examples/password.js).\n\n### Required\n\n#### Synopsis\n\nCheck if a value is present and is not null.\n\n#### Example\n\nSee [`example/required.js`](./examples/required.js).\n\n### Same\n\n#### Synopsis\n\nCheck if a value is equal to another.\n\n#### Example\n\nSee [`example/same.js`](./examples/same.js).\n\n### String\n\n#### Synopsis\n\nCheck if a value is of type string.\n\n#### Example\n\nSee [`example/string.js`](./examples/string.js).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faminnairi%2Fvalidator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faminnairi%2Fvalidator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faminnairi%2Fvalidator/lists"}