{"id":20879221,"url":"https://github.com/7c/autovalidate","last_synced_at":"2026-04-26T14:31:30.904Z","repository":{"id":57093804,"uuid":"459269250","full_name":"7c/autovalidate","owner":"7c","description":"small but well-tested library for input validation for like express or any other input from users","archived":false,"fork":false,"pushed_at":"2024-03-05T15:25:39.000Z","size":22,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-05-05T20:22:53.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":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/7c.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-02-14T17:58:28.000Z","updated_at":"2022-02-14T17:58:50.000Z","dependencies_parsed_at":"2024-01-22T23:24:55.839Z","dependency_job_id":"df9f6755-52d7-4623-b27b-aadefece83bf","html_url":"https://github.com/7c/autovalidate","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/7c%2Fautovalidate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/7c%2Fautovalidate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/7c%2Fautovalidate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/7c%2Fautovalidate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/7c","download_url":"https://codeload.github.com/7c/autovalidate/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243238465,"owners_count":20259119,"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-11-18T07:15:36.686Z","updated_at":"2025-12-25T14:39:23.852Z","avatar_url":"https://github.com/7c.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"## autovalidate\nsmall but well-tested library for input validation\n\n### Installation\n`\nnpm i https://github.com/7c/autovalidate --save\n`\n\n### Features\n- custom validator\n- custom types\n- required / optional keys\n- multiple type support\n- length support for string,arrays(items),object(keycount)\n- min,max support for number\n\n## Types\n\n### Custom Types\nip4,ip6,url,email,hostname\n### Basic Types\nstring,boolean,number,array,object\n\n### validateParameters(inputObject,configuration)\nthis function takes an input object such as `req.body` or `req.params` or any Javascript Hash Object. This function throws an exception in case the configuration is troublesome. This will avoid you as developer from mistakes. Since the configuration is constant, you do not expect an exception at production.\n\n```\nconst  { validateParameters } = require('@7c/autovalidate')\n// OR\nimport { validateParameters } from '@7c/autovalidate'\n\nlet configuration = [\n    { key: 'token', type: ['string'] },\n    { key: 'ip', type: ['ip4'] },\n    { key: 'from', type: ['email'] },\n    {\n        key: 'PayerID', type: ['string'],\n        length: [3, 64],\n        required: false,\n        default: 'NONE'\n    },\n    {\n        key: 'uuid', type: ['string'],\n        required: true,\n        validator: (v) =\u003e validUUID(v)\n    },\n    {\n        key: 'optional', type: ['string', 'boolean'],\n        required: false,\n        default: false\n    },\n    {\n        key: 'theid', type: ['number'],\n        min: 1,\n        required: false,\n        default: false\n    }\n]\nlet response = validateParameters({\n    token: 'validToken',\n    ip: '1.2.3.4',\n    email: 'test@gmail.com'\n}, configuration )\n\nif (response.validated) {\n    console.log(`sucess`)\n} else {\n    console.log(`validation has failed:`,response.issues)\n}\n\n```\n\n## response\nthe response is a structure which has 3 properties: `validated:bool`,`issues:[]`,`values:{}`\n\n### validation failed\nif validation has failed then you will have `validated` set to false, `issues` array will contain explanation why the validation has failed and `values` object will be empty\n```\n{\n  validated: false,\n  issues: [ \"'from' is required\", \"'uuid' is required\" ],\n  values: {}\n}\n```\n\n### validation succeed\nthen `validated` will be true, issues array will be empty and `values` object contains corresponding values\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F7c%2Fautovalidate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2F7c%2Fautovalidate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F7c%2Fautovalidate/lists"}