{"id":20384114,"url":"https://github.com/shipwell/json-yup","last_synced_at":"2025-04-12T09:21:51.585Z","repository":{"id":57152367,"uuid":"226910725","full_name":"shipwell/json-yup","owner":"shipwell","description":"✅ A utility for converting a JSON schema into Yup schema.","archived":false,"fork":false,"pushed_at":"2024-08-31T12:04:13.000Z","size":437,"stargazers_count":16,"open_issues_count":1,"forks_count":1,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-03-26T04:21:33.255Z","etag":null,"topics":["formik-validation","json-schema","json-yup","schema","swagger-schema","swagger-validate","validation","yup","yup-json"],"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/shipwell.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-12-09T16:00:15.000Z","updated_at":"2023-06-01T15:11:39.000Z","dependencies_parsed_at":"2022-08-27T15:24:04.581Z","dependency_job_id":null,"html_url":"https://github.com/shipwell/json-yup","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shipwell%2Fjson-yup","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shipwell%2Fjson-yup/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shipwell%2Fjson-yup/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shipwell%2Fjson-yup/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/shipwell","download_url":"https://codeload.github.com/shipwell/json-yup/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248544039,"owners_count":21121882,"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":["formik-validation","json-schema","json-yup","schema","swagger-schema","swagger-validate","validation","yup","yup-json"],"created_at":"2024-11-15T02:26:05.589Z","updated_at":"2025-04-12T09:21:51.556Z","avatar_url":"https://github.com/shipwell.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# json-yup\n[![npm](https://img.shields.io/npm/v/json-yup.svg?style=flat-square)](https://www.npmjs.com/package/react-native-calendar-events)\n[![npm](https://img.shields.io/npm/l/json-yup.svg?style=flat-square)](https://github.com/wmcmahan/react-native-calendar-events/blob/master/LICENSE.md)\n\nA simple utility for converting a [JSON schema](https://json-schema.org/) into [Yup](https://github.com/jquense/yup) schema.\n\n## Setup\n```\nnpm install -S json-yup\n```\n```\nimport createValidationSchema from 'json-yup';\n```\n\n## API\n\n```javascript\ncreateValidationSchema(schema, options);\n```\n\n### Arguments\n|Argument       | Type  | Description   |\n|-------------- | --- |---|\n|schema      | Object | A valid JSON schema conforming to [JSON schema](https://json-schema.org/) specifications. |\n| customValidationFields | Object | Custom Yup mappings for schema properties |\n\n### Options\n\n|Property       | Type  | Description   |\n|-------------- | --- |---|\n|blackList      | Array | A list of fields to omit from the schema. |\n|customValidationFields | Object | Custom Yup mappings for schema properties |\n|validationTypes| Object | Custom Yup mappings for schema types. |\n\n### Returns\nYup validation object\n\n## Usage\n\n```javascript\n// Valid JSON Schema\nconst jsonSchema = {\n  \"type\": \"object\",\n  \"required\": [\n    \"first_name\"\n  ],\n  \"properties\": {\n    \"create_at\": {\n      \"type\": \"string\"\n    },\n    \"first_name\": {\n      \"type\": \"string\"\n    },\n    \"age\": {\n      \"type\": \"number\",\n      \"min\": 1,\n      \"max\": 200\n    }\n  }\n};\n\n// Build Yup Schema\nconst validationSchema = createValidationSchema(jsonSchema, {\n  blackList: [\n    'create_at'\n  ],\n  validationTypes: {\n    string: yup.string().nullable()\n  },\n  customValidationFields: {\n    first_name: yup.string().test(\n      'isWilly',\n      'Oops! You\\'re not Willy',\n      value =\u003e value === 'Willy'\n    )\n  }\n});\n\n// Check validity\nvalidationSchema.isValid({\n  first_name: 'Willy',\n  age: 24\n})\n\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshipwell%2Fjson-yup","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshipwell%2Fjson-yup","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshipwell%2Fjson-yup/lists"}