{"id":24610675,"url":"https://github.com/rodrigosaint/kaizen-validation","last_synced_at":"2025-03-18T14:44:04.004Z","repository":{"id":57288143,"uuid":"119679544","full_name":"RodrigoSaint/kaizen-validation","owner":"RodrigoSaint","description":"A simple and flexible javascript validation that allows you to test both on backend and frontend.","archived":false,"fork":false,"pushed_at":"2018-05-29T16:04:59.000Z","size":42,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-24T19:17:55.991Z","etag":null,"topics":["backend","extensible","flexible","frontend","javascript","no-dependencies","simple","validation"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/RodrigoSaint.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-01-31T11:40:20.000Z","updated_at":"2018-08-07T17:32:47.000Z","dependencies_parsed_at":"2022-08-28T00:53:32.246Z","dependency_job_id":null,"html_url":"https://github.com/RodrigoSaint/kaizen-validation","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/RodrigoSaint%2Fkaizen-validation","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RodrigoSaint%2Fkaizen-validation/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RodrigoSaint%2Fkaizen-validation/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RodrigoSaint%2Fkaizen-validation/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/RodrigoSaint","download_url":"https://codeload.github.com/RodrigoSaint/kaizen-validation/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244244642,"owners_count":20422339,"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","extensible","flexible","frontend","javascript","no-dependencies","simple","validation"],"created_at":"2025-01-24T19:18:00.184Z","updated_at":"2025-03-18T14:44:03.976Z","avatar_url":"https://github.com/RodrigoSaint.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Kaizen validation ![Build passing](https://travis-ci.org/RodrigoSaint/kaizen-validation.svg?branch=master)\n\nKaizen validation is a javascript package designed to be simple and flexible. It relies on simple javascript functions so you can use it on frontend or backend and with any kind of framework.\n\nTo create a validation using it you only need to import it and invoke the validate method. This method receive two arguments, the validation constraint and the model to be validated. The constraint is a object that should have the attributes that you want to validate on the model and their value should be a array of functions that receive a value and return a string if has a error or undefined if is valid. If all validations pass undefined will be returned.\n\nFor example:\n\n```javascript\nconst validationDefinition = {name: [ name =\u003e name == undefined? \"The name is required\": undefined ]};\nconst modelToValidate = {name: undefined};\nconst result = validate(validationDefinition, modelToValidate);\n//the result will return a object with the attribute name containing a array with \"The name is required\" message\n```\n\nIf you want to create a validation that can depends on another argument you may do it by [currying](https://en.wikipedia.org/wiki/Currying).\n\nFor example:\n\n```javascript\nexport const maxLength = length =\u003e \n    (property =\u003e property !== undefined \u0026\u0026 property.length \u003e length? lengthError : undefined);\n```\n\nThis maxLength function depends on the length argument, when it is invoked it will return a new funcion that can be used on the validation. \n\nThis package also have some built-in validations, but I encourage you to create your own if they not attend. At current time they are:\n\n - **isRequired** - It will validate if the property is undefined.\n - **minLength -** It will validate property's minimum length. It should receive a number as parameter.\n - **maxLength -** It will validate property's maximum length. It should receive a number as parameter.\n - **greatherThan** - It will validate if the property is bigger than its parameter. It should receive a number as parameter.\n - **smallerThan** - It will validate if the property is smaller than its parameter. It should receive a number as parameter.\n - **containsAtArray**- It will validate if a value is at a array. It should receive a array as parameter.\n\nYou may create PRs with new generic validations.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frodrigosaint%2Fkaizen-validation","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frodrigosaint%2Fkaizen-validation","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frodrigosaint%2Fkaizen-validation/lists"}