{"id":24189289,"url":"https://github.com/hdk101/credentials-validator","last_synced_at":"2025-09-21T12:33:20.256Z","repository":{"id":42944262,"uuid":"233881444","full_name":"HDK101/credentials-validator","owner":"HDK101","description":"A quick way to validate credentials in server-side","archived":false,"fork":false,"pushed_at":"2023-01-06T02:25:59.000Z","size":726,"stargazers_count":2,"open_issues_count":10,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-08-08T23:45:51.844Z","etag":null,"topics":["backend","credentials","data","email","frontend","javascript","login","node","npm","npm-install","password","register","server-side"],"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/HDK101.png","metadata":{"files":{"readme":"README.MD","changelog":null,"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-01-14T16:10:43.000Z","updated_at":"2021-10-14T11:46:56.000Z","dependencies_parsed_at":"2023-02-05T03:01:19.287Z","dependency_job_id":null,"html_url":"https://github.com/HDK101/credentials-validator","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/HDK101%2Fcredentials-validator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HDK101%2Fcredentials-validator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HDK101%2Fcredentials-validator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HDK101%2Fcredentials-validator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/HDK101","download_url":"https://codeload.github.com/HDK101/credentials-validator/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":233754738,"owners_count":18725057,"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":["backend","credentials","data","email","frontend","javascript","login","node","npm","npm-install","password","register","server-side"],"created_at":"2025-01-13T14:24:18.869Z","updated_at":"2025-09-21T12:33:14.945Z","avatar_url":"https://github.com/HDK101.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Credentials Validator\n\n![npm](https://img.shields.io/npm/v/credentials-validator)\n[![Build Status](https://travis-ci.com/HDK101/credentials-validator.svg?branch=master)](https://travis-ci.com/HDK101/credentials-validator)\n\n### A quick way to validate credentials in server-side\n\n#### How to install\n\n1. Run npm install\n\n```\nnpm install credentials-validator\n```\n\n2. Write the following code:\n\n```\nconst validator = require(\"credentials-validator\");\n\nuser = {\n  name: \"AnnieCare1010\",\n  email: \"annie@email.com\",\n  password: \"Password10\"\n};\n\nvalidator.validate(user, function(errors) {\n  console.table(errors);\n});\n```\n\nYou will notice that will produce no errors.\nBut what happens if we change the password to \"Pass\", which has only 4 characters?\n\n```\n  password: \"Pass\"\n```\n\nIt will produce...\n\n```\n┌─────────┬────────────────────────────────────────────────────┐\n│ (index) │                       Values                       │\n├─────────┼────────────────────────────────────────────────────┤\n│    0    │ 'Password too short, max length: 8'                │\n└─────────┴────────────────────────────────────────────────────┘\n```\n\nVoila! it produced an error.\n\n### Settings\n\nHere is the available settings:\n\n```\nvar settings = {\n  nameMin: 5,\n  nameMax: 15,\n  passwordMin: 8,\n  passwordMax: 20,\n  passwordMustContainUpper: false,\n  passwordMustContainNumber: false,\n  passwordSpecialCharactersPermit: false\n};\n```\n\nAnd you can change the settings using the setSettings() method\n\n```\nconst validator = require(\"credentials-validator\");\n\nconst newSettings = {\n  nameMin: 10,\n  nameMax: 25,\n  passwordMustContainUpper: false\n};\n\nvalidator.setSettings(newSettings);\n```\n\n### Custom error messages\n\nYou can set custom error messages.\n\n```\nuser = {\n  name: \"AnnieCare1010\",\n  email: \"annie@email.com\",\n  password: \"Password10\"\n};\n\nconst errorMessages = {\n  errorPasswordMin: \"Senha curta, tamanho máximo: __VALUE__\"\n  //__VALUE__ gets replaced by the current value, which is password min length in this case\n};\n\nvalidator.validate(user, function(errors) {\n  console.table(errors);\n});\nvalidator.setErrorMessages(errorMessages);\n```\n\nIt will print...\n\n```\n┌─────────┬──────────────────────────────────┐\n│ (index) │              Values              │\n├─────────┼──────────────────────────────────┤\n│    0    │ 'Senha curta, tamanho máximo: 8' │\n└─────────┴──────────────────────────────────┘\n```\n\n## Other things you must know\n\n### Invidual check methods for name, email and password\n\n```\n\n//A method that individually checks a name\nvalidator.checkName(\"JohnDoe\" ,function(errs) {\n  console.log(errs);\n});\n//A method that individually checks an email\nvalidator.checkEmail(\"john@gmail.com\",function(errs) {\n  console.log(errs);\n});\n//A method that individually checks an password\nvalidator.checkPassword(\"Password10\",function(errs) {\n  console.log(errs);\n});\n\n```\n\n### Check for custom credential\n\nExample:\n```\nconst customCredential = \"AyeMate\"\n\nsettings = {\n  min: 10,\n  max: 20\n};\n/*\nCheck out the full settings in next code sample\n*/\n\nerrorMessages = {\n  errorMin: \"__NAME__ is low! Min length: __VALUE__\"\n};\n/*\n__NAME__ gets replaced by the credential name,\ncheck out the full error message in the next code sample\n*/\n\n//checkCustom(credential, name, callback, customSettings, customErrorMessages);\nvalidator.checkCustom(\n  customCredential,\n  \"Custom credential\",\n  function(errs) {\n    errors.push(errs);\n  },\n  settings,\n  errorMessages\n);\n\n```\n\nFull custom settings and error messages\n```\nlet cSettings = {\n    min: 0,\n    max: 0,\n    mustContainWord: [],\n    mustContainUpper: false,\n    mustContainNumber: false,\n    specialCharactersPermit: true\n};\nlet cErrorMessages = {\n    errorEmpty: \"Empty __NAME__!\",\n    errorMin: \"__NAME__ too short, min length: __VALUE__\",\n    errorMax: \"__NAME__ too long, max length: __VALUE__\",\n    errorWord: \"__NAME__ should contain this word: __VALUE__\",\n    errorUpper: \"__NAME__ should contain at last 1 uppercase!\",\n    errorNumber: \"__NAME__ should contain at last 1 number!\",\n    errorSpecialFalse: \"Forbidden characters in __NAME__\",\n    errorSpecialTrue: \"__NAME__ should contain at last 1 special characters!\"\n};\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhdk101%2Fcredentials-validator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhdk101%2Fcredentials-validator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhdk101%2Fcredentials-validator/lists"}