{"id":18720792,"url":"https://github.com/alibaba-fusion/validate","last_synced_at":"2025-07-07T06:33:37.733Z","repository":{"id":35033225,"uuid":"197341358","full_name":"alibaba-fusion/validate","owner":"alibaba-fusion","description":null,"archived":false,"fork":false,"pushed_at":"2024-02-21T12:11:28.000Z","size":3990,"stargazers_count":1,"open_issues_count":14,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-12T14:25:12.209Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","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/alibaba-fusion.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":"2019-07-17T07:47:44.000Z","updated_at":"2024-01-31T08:55:41.000Z","dependencies_parsed_at":"2024-02-04T10:49:04.688Z","dependency_job_id":"ca42db59-e8b9-468b-8277-a2433c59819f","html_url":"https://github.com/alibaba-fusion/validate","commit_stats":{"total_commits":46,"total_committers":5,"mean_commits":9.2,"dds":0.5434782608695652,"last_synced_commit":"fda7998d238c420db551041fbde7beaaa7a5c2df"},"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/alibaba-fusion/validate","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alibaba-fusion%2Fvalidate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alibaba-fusion%2Fvalidate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alibaba-fusion%2Fvalidate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alibaba-fusion%2Fvalidate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/alibaba-fusion","download_url":"https://codeload.github.com/alibaba-fusion/validate/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alibaba-fusion%2Fvalidate/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264027931,"owners_count":23546161,"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-07T13:32:37.998Z","updated_at":"2025-07-07T06:33:37.700Z","avatar_url":"https://github.com/alibaba-fusion.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Validate\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://www.npmjs.org/package/@alifd/validate\"\u003e\u003cimg src=\"https://img.shields.io/npm/v/@alifd/validate.svg\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://www.npmjs.org/package/@alifd/validate\"\u003e\u003cimg src=\"https://img.shields.io/npm/dm/@alifd/validate.svg\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://codecov.io/gh/alibaba-fusion/validate\"\u003e\u003cimg src=\"https://codecov.io/gh/alibaba-fusion/validate/branch/master/graph/badge.svg\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://travis-ci.com/alibaba-fusion/validate\"\u003e\u003cimg src=\"https://travis-ci.com/alibaba-fusion/validate.svg?branch=master\"\u003e\u003c/a\u003e\n  \u003ca href=\"http://makeapullrequest.com\"\u003e\u003cimg src=\"https://img.shields.io/badge/PRs-welcome-brightgreen.svg\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://github.com/alibaba-fusion/validate/blob/master/LICENSE\"\u003e\u003cimg src=\"https://img.shields.io/badge/license-MIT-brightgreen.svg\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://github.com/semantic-release/semantic-release\"\u003e\u003cimg src=\"https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n\nValidation to be used with @alifd/field\nInstall with `npm install @alifd/validate`\n\n### Basic Usage\n\n#### Callback\n```\nconst rules = {\n  myInput: function (rule, value, cb, options) {\n    if (value \u003c= 100) {\n      cb('Value must be more than 100');\n    } else {\n      cb();\n    }\n  }\n}\nconst validator = new Validator(rules);\nvalidator.validate({ myInput: 90 }, (err) =\u003e { console.log(err)});\n```\n\n#### Promise\n```\nconst rules = {\n  myInput: function (rule, value, cb, options) {\n    if (value \u003c= 100) {\n      cb('Value must be more than 100');\n    } else {\n      cb();\n    }\n  }\n}\nconst validator = new Validator(rules);\nvalidator.validatePromise({ myInput: 90 })\n  .then((err) =\u003e { console.log(err)})\n```\n\n## API\n### Initialization\n```\nlet validator = new Validator(rules [, options]);\n```\n\n|Parameter | Description | Type | Optional |Default |\n|-----------|------------------------------------------|------------|-------|--------|\n| rules | Map of rule names to validation functions | { [ruleName] : Array of validation functions } | yes | undefined\n| options | validation options | Object | yes | {} |\n\n`options` configuration item\n\n| Parameters | Description | Type |Default |\n|-----------|------------------------------------------|-----------|--------|\n| first | should only return the first error found amongst rules | Boolean | undefined\n| messages | map to override default messages | Object | (see ./src/messages)\n\n\n\n## Development\n\n### Testing\n`npm run test` - triggers a one-time full run of all unit tests\n`npm run test-watch` - triggers a run of all unit tests, but watches for any changes to code or tests and reruns all tests.\n\n\n### Making commits\nCommits must be in the following format `TYPE(SCOPE): MESSAGE`, where `SCOPE` is optional.\ne.g. `fix: validatePromise return value`\nReview the `commitlint.config.js` file to see allowed types.\n\n### Release\nThere are 2 main branches: Master and Develop. Master holds the latest code that is contained in the npm package. Develop is the development branch used for queueing package changes and any final validation. All development should occur on another branch and then be merged into Develop. \n\nTravis CI will run tests on each pull request and push. If the push is to master then an additional release step runs. The release step uses `semantic-release` to determine the correct version, tag the master branch, and release the new package to npm. \n\nNOTE: the package.json file needs to be updated manually after the release.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falibaba-fusion%2Fvalidate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falibaba-fusion%2Fvalidate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falibaba-fusion%2Fvalidate/lists"}