{"id":13414777,"url":"https://github.com/danielweinmann/validate-model","last_synced_at":"2025-04-11T15:36:58.204Z","repository":{"id":57390224,"uuid":"52284001","full_name":"danielweinmann/validate-model","owner":"danielweinmann","description":"Validate model objects with validator.js","archived":false,"fork":false,"pushed_at":"2018-03-30T09:12:02.000Z","size":6,"stargazers_count":10,"open_issues_count":3,"forks_count":4,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-10-11T18:09:19.450Z","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/danielweinmann.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}},"created_at":"2016-02-22T15:40:02.000Z","updated_at":"2023-09-07T01:32:40.000Z","dependencies_parsed_at":"2022-09-19T04:02:26.965Z","dependency_job_id":null,"html_url":"https://github.com/danielweinmann/validate-model","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielweinmann%2Fvalidate-model","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielweinmann%2Fvalidate-model/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielweinmann%2Fvalidate-model/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielweinmann%2Fvalidate-model/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/danielweinmann","download_url":"https://codeload.github.com/danielweinmann/validate-model/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248432255,"owners_count":21102340,"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-07-30T21:00:36.472Z","updated_at":"2025-04-11T15:36:58.179Z","avatar_url":"https://github.com/danielweinmann.png","language":"JavaScript","funding_links":[],"categories":["An Node JS supercool REST API"],"sub_categories":[],"readme":"# validate-model\n\nValidate model objects with [validator.js](https://github.com/chriso/validator.js). Read validator.js documentation to see available validators.\n\n## Installation\n\n```npm install validate-model --save```\n\n## Usage\n\n```js\nvar ValidateModel = require('validate-model');\nvar validate = ValidateModel.validate;\nvar validateAll = ValidateModel.validateAll;\n\nvar UserValidators = {\n  name: {\n    title: 'Name',\n    validate: [{\n      validator: 'isLength',\n      arguments: [1, 255],\n    }]\n  },\n  email: {\n    title: 'Email',\n    validate: [{\n      validator: 'isLength',\n      arguments: [20, 255],\n      message: '{TITLE} is too short'\n    },\n    {\n      validator: 'isEmail',\n      message: '{TITLE} must be valid'\n    }]\n  },\n  password: {\n    title: 'Password',\n    validate: [{\n      validator: 'isLength',\n      arguments: [8, 255],\n      message: '{TITLE} is too short'\n    }]\n  }\n};\n\nvar user = {\n  name: 'Foo',\n  email: 'invalid@email',\n  password: 'short'\n};\n\nvar nameValidation = validate(UserValidators.name, user.name);\n// { valid: true, messages: [] }\n\nvar emailValidation = validate(UserValidators.email, user.email);\n// { valid: false, messages: ['Email is too short', 'Email must be valid'] }\n\nvar passwordValidation = validate(UserValidators.password, user.password);\n// { valid: false, messages: ['Password is too short'] }\n\nvar userValidation = validateAll(UserValidators, user)\n// { valid: false, messages: {email: ['Email is too short', 'Email must be valid'], password: ['Password is too short']}}\n\n```\n\n## Inspiration\n\nThis package is inspired by the way [FaridSafi/react-native-gifted-form](https://github.com/FaridSafi/react-native-gifted-form) implements form validation.\n\n## Contributing\n\nPlease create issues and send pull requests!\n\n## License\n\n[MIT](LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanielweinmann%2Fvalidate-model","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdanielweinmann%2Fvalidate-model","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanielweinmann%2Fvalidate-model/lists"}