{"id":23138482,"url":"https://github.com/deployable/deployable-validate","last_synced_at":"2025-04-04T09:44:23.824Z","repository":{"id":149113370,"uuid":"75616142","full_name":"deployable/deployable-validate","owner":"deployable","description":"Javascript Validation Helpers","archived":false,"fork":false,"pushed_at":"2017-03-17T04:13:37.000Z","size":34,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-09T20:28:12.848Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"CoffeeScript","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/deployable.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":"2016-12-05T10:56:12.000Z","updated_at":"2016-12-05T11:49:11.000Z","dependencies_parsed_at":"2023-04-26T01:01:32.027Z","dependency_job_id":null,"html_url":"https://github.com/deployable/deployable-validate","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deployable%2Fdeployable-validate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deployable%2Fdeployable-validate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deployable%2Fdeployable-validate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deployable%2Fdeployable-validate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/deployable","download_url":"https://codeload.github.com/deployable/deployable-validate/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247157133,"owners_count":20893210,"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-17T13:10:58.404Z","updated_at":"2025-04-04T09:44:23.778Z","avatar_url":"https://github.com/deployable.png","language":"CoffeeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# deployable-validate\n\nValidation helpers\n\nStatic methods\n\n``` javascript\n\nconst Validate = require('deployable-validate')\n\nlet goodword = 'asdf'\nlet badword = 'a word'\n\nValidate.as('alpha', goodword, \"goodword\")  // =\u003e true\nValidate.as('alpha', badword, \"badword\")    // =\u003e false\n\nlet notint = 6.6\n\nValidate.a('integer', notint )              // =\u003e false\nValidate.toMessage('integer', notint )      // =\u003e \"Value must be an integer\"\nValidate.toError('integer', notint )        // =\u003e ValidationError: \"Value must be an integer\"\n\nValidate.andThrow('integer', notint ) \nValidationError: Value must be an integer\n    at ValidateTest.getError (/clones/deployable-validate/lib/validate_test.js:149:15)\n    at Function.andThrow (/clones/deployable-validate/lib/validate.js:68:46)\n```\n\nAnd a validate instance to build validation suites to run.\n\n``` javascript\n\nlet input = 3\nlet word = 'testing'\nvalidate = new Validate({ throw: true })\n  .add('numeric', '1345432')\n  .add('alphaNumeric', 'asdf234324')\n  .add('range', input, 1, 6, 'input')\n  .add('match', word, /whatever/, 'word')\n  .run()\n\n```\n\n## run() Modes\n\n#### `{ throw: true }`\n\nThrow an error as it occurs. The default.\n\n#### `{ error: true }`\n\nReturn all error objects\n\n#### `{ message: true }`\n\nReturn all error message\n\n#### `{ results: true }`\n\nReturn all results, including inputs as an array\n\n\n###  Message templates\n\nError message can be customised via mustache style template strings.\n\nEvery test has a `value` to be tested and a `name` that default to `Value` if not supplied. \n\n    \"Field {{name}} should be a X. Instead it was {{value}}\"\n\nAdditional arguments can be names in each validation tests configuration. \n\n[lib/validate_config.js](https://github.com/deployable/deployable-validate/blob/master/lib/validate_config.js)\n\n``` javascript\n\n  match: {\n    args: ['string', 'regex'],\n    test: ( string, regex ) =\u003e ( _.isString(string) \u0026\u0026 Boolean(string.match(regex)) ),\n    message: '{{name}} must match regular expression {{regex}}',\n    group: 'string'\n  }\n\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdeployable%2Fdeployable-validate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdeployable%2Fdeployable-validate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdeployable%2Fdeployable-validate/lists"}