{"id":14155538,"url":"https://github.com/ftonato/nope-validator","last_synced_at":"2025-05-16T15:02:28.809Z","repository":{"id":36978421,"uuid":"193401250","full_name":"ftonato/nope-validator","owner":"ftonato","description":"A small, simple, and fast JS validator. Like, wow that's fast. 🚀","archived":false,"fork":false,"pushed_at":"2024-06-06T03:37:55.000Z","size":2966,"stargazers_count":346,"open_issues_count":19,"forks_count":15,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-05-14T11:51:35.686Z","etag":null,"topics":["form","form-validation","forms","javascript","object","schema","typescript","validation","validator"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/nope-validator","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/ftonato.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG","contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","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":"ftonato"}},"created_at":"2019-06-23T22:27:14.000Z","updated_at":"2025-04-24T12:06:43.000Z","dependencies_parsed_at":"2024-01-16T22:19:04.872Z","dependency_job_id":"b47fab9d-7241-473c-beed-ed6585a3e103","html_url":"https://github.com/ftonato/nope-validator","commit_stats":{"total_commits":202,"total_committers":13,"mean_commits":"15.538461538461538","dds":0.7079207920792079,"last_synced_commit":"6501f62bc429d4b723371ba47c6e10da45e2a317"},"previous_names":["bvego/nope-validator"],"tags_count":26,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ftonato%2Fnope-validator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ftonato%2Fnope-validator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ftonato%2Fnope-validator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ftonato%2Fnope-validator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ftonato","download_url":"https://codeload.github.com/ftonato/nope-validator/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254553936,"owners_count":22090415,"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","form-validation","forms","javascript","object","schema","typescript","validation","validator"],"created_at":"2024-08-17T08:03:48.602Z","updated_at":"2025-05-16T15:02:28.738Z","avatar_url":"https://github.com/ftonato.png","language":"TypeScript","readme":"# Nope 🙅\n\n[![CircleCI](https://circleci.com/gh/ftonato/nope-validator.svg?style=svg)](https://circleci.com/gh/ftonato/nope-validator)\n[![Fast](https://badgen.now.sh/badge/speed/really%20fast/green)](https://npm.im/nope-validator)\n[![Version](https://img.shields.io/npm/v/nope-validator.svg)](https://npm.im/nope-validator)\n[![size](https://img.shields.io/bundlephobia/min/nope-validator.svg)](https://bundlephobia.com/result?p=nope-validator)\n[![gzip](https://img.shields.io/bundlephobia/minzip/nope-validator.svg)](https://bundlephobia.com/result?p=nope-validator)\n\n\u003e \u003csup\u003eThis project was created by the awesome **[Bruno Vego - @bvego](https://github.com/bvego)**, and is currently maintained by [@ftonato](https://github.com/ftonato) and the community.\u003c/sup\u003e\n\n---\n\nA small, simple and fast JS validator. Like, wow thats fast. 🚀\n\nNope's API is ~~heavily inspired~~ stolen from [Yup](https://github.com/jquense/yup) but Nope attempts to be much smaller and much faster. To achieve this Nope only allows for synchronous data validation which should cover most of the use cases.\n\n### Note: Nope is not a plug-and-play replacement for Yup, in some cases at least.\n\nInstead of throwing errors Nope simply returns the error object and if there are no errors it returns undefined.\n\nFor more details on what's available in Nope, check out the [documentation](https://github.com/ftonato/nope-validator/wiki).\n\nTypescript definitions included. ✨\n\n- [Getting started](#getting-started)\n- [Usage with react-hook-form](#usage-with-react-hook-form)\n- [Usage with Formik](#usage-with-formik)\n\n## Getting started\n\nTo start using Nope simply do\n\n```sh\nyarn add nope-validator\n```\n\nor\n\n```sh\nnpm install -S nope-validator\n```\n\nor (even), do you wanna to **[try it online](https://replit.com/@ftonato/nope-validator-with-nodeJS)**?\n\n```js\n// import the dependency on your app\n\n// const Nope = require('nope-validator'); // or\n// const { Nope } = require('nope-validator'); // or\nimport Nope from 'nope-validator';\n```\n\n```js\n// create a schema\n\nconst UserSchema = Nope.object().shape({\n  name: Nope.string().atLeast(5, 'Please provide a longer name').atMost(255, 'Name is too long!'),\n  email: Nope.string().email().required(),\n  confirmEmail: Nope.string()\n    .oneOf([Nope.ref('email')])\n    .required(),\n});\n\nUserSchema.validate({\n  name: 'John',\n  email: 'me@gmail.com',\n  confirmEmail: 'me@gmail.com',\n}); // returns an error object { name: 'Please provide a longer name '};\n\nUserSchema.validate({\n  name: 'Jonathan Livingston',\n  email: 'me@gmail.com',\n  confirmEmail: 'me@gmail.com',\n}); // returns undefined since there are no errors\n```\n\n## Usage with [react-hook-form](https://github.com/react-hook-form/react-hook-form)\n\nHuge thanks to the RHF team for making a resolver for nope, enabling you to use nope as a validator in your RHF-controlled forms.\n\n```jsx\nimport { nopeResolver } from '@hookform/resolvers/nope';\nimport { useForm } from 'react-hook-form';\nimport * as Nope from 'nope-validator';\n\nconst schema = Nope.object().shape({\n  username: Nope.string().required(),\n  password: Nope.string().required(),\n});\n\nfunction Component({ onSubmit }) {\n  const {\n    register,\n    formState: { errors },\n    handleSubmit,\n  } = useForm({\n    resolver: nopeResolver(schema),\n  });\n\n  return (\n    \u003cform onSubmit={handleSubmit(onSubmit)}\u003e\n      \u003cinput {...register('username')} /\u003e\n      {errors.username \u0026\u0026 \u003cdiv\u003e{errors.username.message}\u003c/div\u003e}\n\n      \u003cinput {...register('password')} /\u003e\n      {errors.password \u0026\u0026 \u003cdiv\u003e{errors.password.message}\u003c/div\u003e}\n\n      \u003cbutton type=\"submit\"\u003esubmit\u003c/button\u003e\n    \u003c/form\u003e\n  );\n}\n```\n\n## Usage with [Formik](https://github.com/jaredpalmer/formik)\n\nInstead of passing it through the `validationSchema` prop, you should call Nope's validate on the `validate` prop as shown in the example below.\n\n```jsx\nimport { Formik } from 'formik';\nimport * as Nope from 'nope-validator';\n\nconst schema = Nope.object().shape({\n  username: Nope.string().required(),\n  password: Nope.string().required(),\n});\n\nfunction Component({ onSubmit }) {\n  return (\n    \u003cFormik\n      initialValues={{ username: '', password: '' }}\n      validate={(values) =\u003e schema.validate(values)}\n      onSubmit={(values) =\u003e console.log('Submitted', values)}\n    \u003e\n      {() =\u003e (\n        \u003cForm\u003e\n          \u003cField type=\"username\" name=\"username\" /\u003e\n          \u003cErrorMessage name=\"username\" component=\"div\" /\u003e\n\n          \u003cField type=\"password\" name=\"password\" /\u003e\n          \u003cErrorMessage name=\"password\" component=\"div\" /\u003e\n\n          \u003cbutton type=\"submit\"\u003eSubmit\u003c/button\u003e\n        \u003c/Form\u003e\n      )}\n    \u003c/Formik\u003e\n  );\n}\n```\n\n## Contribute\n\nInformation describing how to contribute can be found **[here](https://github.com/ftonato/nope-validator/blob/master/CONTRIBUTING.md)** 🎉\n\n## License\n\n[MIT](LICENSE)\n","funding_links":["https://github.com/sponsors/ftonato"],"categories":["typescript"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fftonato%2Fnope-validator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fftonato%2Fnope-validator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fftonato%2Fnope-validator/lists"}