{"id":22428393,"url":"https://github.com/momsfriendlydevco/joyful","last_synced_at":"2025-03-27T06:43:44.460Z","repository":{"id":190294557,"uuid":"682346735","full_name":"MomsFriendlyDevCo/Joyful","owner":"MomsFriendlyDevCo","description":"Tiny wrapper around Joi to provide easy validation + errors","archived":false,"fork":false,"pushed_at":"2023-10-09T02:00:21.000Z","size":24,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-25T12:50:54.889Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/MomsFriendlyDevCo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2023-08-24T01:24:52.000Z","updated_at":"2023-08-24T01:25:17.000Z","dependencies_parsed_at":"2023-08-24T01:32:24.598Z","dependency_job_id":"9bbb0389-07f0-463e-92ca-c263ef956263","html_url":"https://github.com/MomsFriendlyDevCo/Joyful","commit_stats":null,"previous_names":["momsfriendlydevco/joyful"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MomsFriendlyDevCo%2FJoyful","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MomsFriendlyDevCo%2FJoyful/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MomsFriendlyDevCo%2FJoyful/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MomsFriendlyDevCo%2FJoyful/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MomsFriendlyDevCo","download_url":"https://codeload.github.com/MomsFriendlyDevCo/Joyful/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245798538,"owners_count":20673901,"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":[],"created_at":"2024-12-05T20:14:42.016Z","updated_at":"2025-03-27T06:43:44.442Z","avatar_url":"https://github.com/MomsFriendlyDevCo.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"@MomsFriendlyDevCo/Joyful\n=========================\nTiny wrapper around [Joi](https://joi.dev/api) to provide easy validation + errors.\n\nWhy?\n\n* *Simple terse format* - No need to wrap outer objects in `Joi.object()`, POJOs and simple structures are converted for you\n* *Verbose Joi imports* - By using a callback you can avoid needing to import Joi as a library in your outer library, just import it for the validation construction and let it fall out of scope\n* *Meaningful errors* - Joi, while wonderful, doesn't make extracting errors easy, this library combines validation errors together and makes them readable as one string, readable by a human\n* *Throw by default* - Validation failures throw (configurable) by default without needing to examine the result and pick apart if an error occurred\n\n\nExamples\n--------\n\n### Terse syntax\nIf given a callback, `joyful()` will call that function with `(Joi)` as the only argument, avoiding the need to `import Joi` into your outer application\n\n```javascript\nimport joyful from '@momsfriendlydevco/joyful';\n\njoyful(\n    {foo: 'Foo!'},\n    joi =\u003e ({foo: joi.string().required()}}),\n); //= true\n\njoyful(\n    {},\n    joi =\u003e ({foo: joi.string().required()}}),\n); //~ will throw a meaningful error\n```\n\n### Verbose syntax\nOr if you prefer the exactness of using Joi, use it as a regular validator.\n\n```javascript\nimport joyful from '@momsfriendlydevco/joyful';\nimport Joi from 'joi';\n\n// Full verbose syntax to validate an object\njoyful(\n    {foo: 'Foo!'},\n    Joi.Object({foo: Joi.string().required()}),\n); //= true\n\n// Shorter - pass a POJO instead of the wrapping `Joi.object()`\njoyful(\n    {foo: 'Foo!'},\n    {foo: Joi.string().required()},\n); //= true\n```\n\n\nAPI\n===\n\njoyful(data, schema, options)\n=============================\nThis library exposes a simple function `joyful(data, schema, options)` which accepts:\n\n* _data_ - The input data to validate\n* _schema_ - A `Joi.Object()`, A [POJO](https://www.wikiwand.com/en/Plain_Old_Java_Object) or a function which can return either. Can also be an array of any of these which are merged in order\n* _options_ - Additional options to change the functions behaviour\n\nOptions are:\n\n| Option  | Type      | Default | Description                                                                                                 |\n|---------|-----------|---------|-------------------------------------------------------------------------------------------------------------|\n| `throw` | `Boolean` | `true`  | Throw an error if validation fails, otherwise the return value will be the string contents that would throw |\n\n\njoyful.joi\n----------\n`joi` instance.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmomsfriendlydevco%2Fjoyful","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmomsfriendlydevco%2Fjoyful","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmomsfriendlydevco%2Fjoyful/lists"}