{"id":20775327,"url":"https://github.com/knicola/yup-password","last_synced_at":"2025-07-21T00:33:50.156Z","repository":{"id":37939373,"uuid":"307579638","full_name":"knicola/yup-password","owner":"knicola","description":"Yup, dead simple password validation.","archived":false,"fork":false,"pushed_at":"2024-06-16T15:07:09.000Z","size":489,"stargazers_count":48,"open_issues_count":2,"forks_count":6,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-07-04T11:01:47.303Z","etag":null,"topics":["browser","javascript","nodejs","password","validation","yup"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/knicola.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"knicola","patreon":null,"open_collective":null,"ko_fi":"kyriakos","tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":null}},"created_at":"2020-10-27T03:54:48.000Z","updated_at":"2024-09-07T07:37:11.000Z","dependencies_parsed_at":"2024-06-18T16:43:23.340Z","dependency_job_id":"d31fcaf6-0221-407a-acb8-de126a64f0f5","html_url":"https://github.com/knicola/yup-password","commit_stats":{"total_commits":54,"total_committers":2,"mean_commits":27.0,"dds":"0.12962962962962965","last_synced_commit":"82e8b08c94579e72ebfe534e71de6a4bea4c7d60"},"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/knicola/yup-password","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/knicola%2Fyup-password","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/knicola%2Fyup-password/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/knicola%2Fyup-password/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/knicola%2Fyup-password/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/knicola","download_url":"https://codeload.github.com/knicola/yup-password/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/knicola%2Fyup-password/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266221376,"owners_count":23894966,"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":["browser","javascript","nodejs","password","validation","yup"],"created_at":"2024-11-17T12:35:37.722Z","updated_at":"2025-07-21T00:33:45.143Z","avatar_url":"https://github.com/knicola.png","language":"TypeScript","funding_links":["https://github.com/sponsors/knicola","https://ko-fi.com/kyriakos"],"categories":[],"sub_categories":[],"readme":"# Yup-Password\n\n[Yup](https://github.com/jquense/yup), dead simple password validation.\n\n\n## Install\n\nUsing npm:\n```sh\n$ npm install yup-password\n```\n\nUsing yarn:\n```sh\n$ yarn add yup-password\n```\n\n\n## Usage\nPlug and play:\n```js\n// MJS / TS\nimport * as yup from 'yup'\nimport YupPassword from 'yup-password'\nYupPassword(yup) // extend yup\n```\n```js\n// CJS\nconst yup = require('yup')\nrequire('yup-password')(yup) // extend yup\n```\n```js\n// Build schema\nconst schema = yup.object().shape({\n    username: yup.string().email().required(),\n    password: yup.string().password().required(),\n})\n\nconst input = {\n    username: 'user@example.com',\n    password: 'secret',\n}\n\ntry {\n    // validate\n    const res = await schema.validate(input, { abortEarly: false })\n    //  ...\n} catch (e) {\n    console.log(e.errors) // =\u003e [\n    //   'password must be at least 8 characters',\n    //   'password must contain at least 1 uppercase letter',\n    //   'password must contain at least 1 number',\n    //   'password must contain at least 1 symbol',\n    // ]\n}\n```\nOverride, disable or add additional rules:\n```js\nconst schema = yup.string().password()\n    .minLowercase(8) // raise the lowercase requirement to 8\n    .min(0) // disable minimum characters completely\n    .minWords(2) // add an additional rule\n\ntry {\n    const res = await schema.validate('secret', { abortEarly: false })\n    //  ...\n} catch(e) {\n    console.log(e.errors) // =\u003e [\n    //   'password must contain at least 2 words',              \u003c-- added\n    //   'password must contain at least 8 lowercase letters',  \u003c-- overridden\n    //   'password must contain at least 1 uppercase letter',\n    //   'password must contain at least 1 number',\n    //   'password must contain at least 1 symbol',\n    // ]\n}\n```\nPick and choose your password rules:\n```js\nconst schema = yup.string().min(6).minUppercase(3).maxRepeating(2).minWords(2)\n\nawait schema.isValid('Now, THIS is some password.') // =\u003e true\nawait schema.isValid('But thiiis is not.') // =\u003e false\n```\nLocalize your error messages:\n```js\nyup.setLocale({\n    string: {\n        minLowercase: 'Localized message (path=${path};length=${length})',\n        minUppercase: 'Localized message (path=${path};length=${length})',\n        minNumbers: 'Localized message (path=${path};length=${length})',\n        minSymbols: 'Localized message (path=${path};length=${length})',\n        maxRepeating: 'Localized message (path=${path};length=${length})',\n        minWords: 'Localized message (path=${path};length=${length})',\n    }, // when using typescript, you may want to append `as any` to the end\n       // of this object to avoid type errors.\n})\n```\n\n## API\n\n#### .password()\nPassword must meet the default requirements: at least 8 characters, at most 250 characters, at least 1 lowercase letter, at least 1 uppercase letter, at least 1 number and at least 1 symbol.\n```js\nconst schema = yup.string().password()\n```\n\n#### .minLowercase(length?: number = 1, message?: string)\nPassword must contain X amount of lowercase letters or more.\n```js\nconst schema = yup.string().minLowercase(3, 'custom message')\n```\n\n#### .minUppercase(length?: number = 1, message?: string)\nPassword must contain X amount of uppercase letters or more.\n```js\nconst schema = yup.string().minUppercase(3, 'custom message')\n```\n\n#### .minNumbers(length?: number = 1, message?: string)\nPassword must contain X amount of numbers or more.\n```js\nconst schema = yup.string().minNumbers(3, 'custom message')\n```\n\n#### .minSymbols(length?: number = 1, message?: string)\nPassword must contain X amount of symbols or more.\n```js\nconst schema = yup.string().minSymbols(3, 'custom message')\n```\n\n#### .maxRepeating(length?: number = 2, message?: string)\nPassword must not contain a sequence of X amount of repeated characters. For example, if the limit is 2 `thiis` will pass but `thiiis` will not.\n```js\nconst schema = yup.string().maxRepeating(3, 'custom message')\n```\n\n#### .minWords(length?: number = 2, message?: string)\nPassword must contain X amount of words or more. So long as a sequence of characters contains letters or numbers,\nit will be recognized as a word. For example `secret`, `1st!` and `1337` count as words, but `!@#$%` does not.\n```js\nconst schema = yup.string().minWords(3, 'custom message')\n```\n\n## License\n\nThis project is open-sourced software licensed under the [MIT license](./LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fknicola%2Fyup-password","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fknicola%2Fyup-password","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fknicola%2Fyup-password/lists"}