{"id":20976871,"url":"https://github.com/aghabeiki/paramvalidator","last_synced_at":"2026-04-27T06:33:48.074Z","repository":{"id":78673873,"uuid":"99987156","full_name":"Aghabeiki/paramValidator","owner":"Aghabeiki","description":"A multipurpose param validator for SailsJS","archived":false,"fork":false,"pushed_at":"2017-11-16T08:36:38.000Z","size":36,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2026-01-01T01:13:41.450Z","etag":null,"topics":["middle-ware","param-validator","sailsjs"],"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/Aghabeiki.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,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-08-11T03:19:14.000Z","updated_at":"2017-08-11T05:30:49.000Z","dependencies_parsed_at":null,"dependency_job_id":"ec356f15-48ea-45f6-be80-c2b4ca3c3624","html_url":"https://github.com/Aghabeiki/paramValidator","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Aghabeiki/paramValidator","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Aghabeiki%2FparamValidator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Aghabeiki%2FparamValidator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Aghabeiki%2FparamValidator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Aghabeiki%2FparamValidator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Aghabeiki","download_url":"https://codeload.github.com/Aghabeiki/paramValidator/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Aghabeiki%2FparamValidator/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32326110,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-26T23:26:28.701Z","status":"online","status_checked_at":"2026-04-27T02:00:06.769Z","response_time":128,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["middle-ware","param-validator","sailsjs"],"created_at":"2024-11-19T04:56:13.176Z","updated_at":"2026-04-27T06:33:44.898Z","avatar_url":"https://github.com/Aghabeiki.png","language":"JavaScript","readme":"# Param-Validator\n\nA Param Validator in Middleware for Sailsjs/Express.js\n\n**note**: \\\n***this project is under heavy developments.***\n### Installing\n\nInstall node module\n\n```\nnpm i param-validator\n```\n\nAdd it as a middelware to your sails http.js .\n\n```\n paramValidator: function (req, res, next) {\n \tlet paramValidator = new ParamValidator(sails.config.ParamValidator\n    \t, sails.log, sails.config.routes, sails.config.environment);\n    paramValidator.validator(req, res, next);\n},\n```\n#### Config :\n\nCreate a config file under Config folder with any name and put this content on it.\n\n```\nmodule.exports.ParamValidator = {\n    projectBaseDIR: require('path').resolve(__dirname, '../'),\n    validatorBaseRepo: 'api/ParamValidator/ValidatorBank',\n    scriptBaseRepo: 'api/ParamValidator/ValidatorBank/script',\n    excludePrefix: '^(\\/upload\\/center).*$',\n}\n```\n\n* ###### validatorBaseRepo :\n\tThis config is required, and point to the path of your JSON defenition of param validation\n\n* ###### scriptBaseRepo :\n\tThis cinfig is required, and point to the path  of your script defenition of param validation\n\n* ##### excludePrefix :\n\tA regex that exclude any path from param validator\n\n\n##### Param Validator\n\n ###### The JSON Object properties\n\n * **URL** \\\n            The URL that should validate ( should be like route config )\n * METHOD \\\n \t\t\tThe METHOD should be GET, PUT, DELETE or POST\n * BODY or SCRIPT \\\n \t\t\tThe way of validations :D\n\n ###### Validation config\n * BODY : In this method, you can define a JSON file to validate your param automatically\n \t* Independed properties\n \t\t* `type` : number, date, string, array, object, email, phone, boolean`\n \t\t\t*  Multi data type could assign to a param with separator `|`\n \t\t* `required`: define the param is required or not,default value is true\n    * Depend properties\n    \t* type `number`\n    \t\t* min :  minimum acceptable value\n    \t\t* max :  maximum acceptable value\n        * type `string`\n        \t* minLength : minimum acceptable lenght of string\n        \t* maxLength : maximum acceptable lenght of string\n        \t* length : acceptable lenght of string\n      \t* type `array`\n      \t\t* rows: in the rows we can define the param and flow the validation config as well.\n        * type `object`\n        \t* body: the properties of the JSON Object and can use all the validation config as well.\n\n \t* Addition operation\n \t\t* `compareWithFiled` :  compare one pram with another ones\n        \t* this param defined as an array, each rows of this arrasy should defined with a single string like ` operator:param_name `\n        \t* acceptable operators: all the valid logical compare operand in JS!\n        * `regex64` : validate a param with regex,this param should define in config file as an regex that encoded with base64\n\n * SCRIPT: In this method you can write your own script to validate your param in your way\n \t* this param should contain the path of your validatior script file\n \t* the file should be under your `scriptBaseRepo` path\n \t* in valid param checking the script should return `true` value\n \t* on any invalidation just throw an Error\n \t* any Error message that you throwen will be send and formated in response\n \t* the script file should be like :\n\n```\n\t module.exports.validator = function (params) {\n \t\t \"use strict\";\n\n  \t\treturn true;\n\t}\n```\n#### Some Validator Config\n* **Simple JSON Config**\n```\n\t{\n  \"URL\": \"/test/:param1/callcenter/:param2\",\n  \"METHOD\": \"GET\",\n  \"BODY\": {\n    \"param1\": {\n      \"type\": \"number\"\n    },\n    \"param2\": {\n      \"type\": \"number\",\n      \"min\": 1,\n      \"max\": 4,\n      \"required\": false\n    },\n  }\n}\n```\n* **Array Base JSON Config**\n```\n[\n  {\n    \"URL\": \"/test1\",\n    \"METHOD\": \"get\",\n    \"BODY\": {\n     \"date_from\": {\n      \"type\": \"date\",\n      \"required\": false,\n      \"regex64\": \"aBase64String\",\n      \"compareWithFiled\": [\n        \"\u003c:date_to\"\n      ]\n    },\n    \"date_to\": {\n      \"type\": \"date\",\n      \"required\": false,\n      \"regex64\": \"aBase64String\",\n      \"compareWithFiled\": [\n        \"\u003e:date_from\"\n      ]\n    }\n    }\n  },\n  {\n    \"URL\": \"/test2\",\n    \"METHOD\": \"get\",\n    \"SCRIPT\": \"./script/testScript2.js\"\n  }\n]\n```\n* ***single JSON Config***\n```\n{\n\t\"URL\": \"/test3\",\n    \"METHOD:\"post\",\n    \"BODY\":{\n     \"details\": {\n      \"type\": \"array\",\n      \"required\": false,\n      \"rows\": {\n        \"type\": \"object\",\n        \"body\": {\n          \"detail_id\": {\n            \"type\": \"number\"\n          },\n          \"language\": {\n            \"type\": \"string\",\n            \"required\": false,\n            \"regex64\": \"aBase64String\",\n            \"length\": 5\n          },\n          \"title\": {\n            \"type\": \"string\",\n            \"required\": false,\n            \"maxLength\": 1024\n          },\n          \"channel\": {\n            \"type\": \"string\",\n            \"required\": false\n          }\n        }\n      }\n    }\n    }\n}\n```\n* ***A complext Config Desing***\n```\n{\n  \"group a\": [\n    {\n      \"URL\": \"/test5/:id\",\n      \"METHOD\": \"DELETE\",\n      \"SCRIPT\": \"./script/something.js\"\n    },\n    {\n      \"URL\": \"/test6\",\n      \"METHOD\": \"POST\",\n      \"SCRIPT\": \"./script/something2.js\"\n    }\n  ],\n  \"group b\": [\n    {\n      \"URL\": \"/test7\",\n      \"METHOD\": \"PUT\",\n      \"SCRIPT\": \"./script/something3.js\"\n    }\n  ]\n}\n\n```\n\n\n\n\n## Authors\n\n* **Amin Aghabeiki**\n\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faghabeiki%2Fparamvalidator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faghabeiki%2Fparamvalidator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faghabeiki%2Fparamvalidator/lists"}