{"id":28729765,"url":"https://github.com/didi/slime-validator","last_synced_at":"2025-06-15T17:11:00.316Z","repository":{"id":50093324,"uuid":"370311536","full_name":"didi/slime-validator","owner":"didi","description":"JavaScript library of validation based on Plugin system and make data validation be easy.","archived":false,"fork":false,"pushed_at":"2023-02-17T01:44:51.000Z","size":41,"stargazers_count":86,"open_issues_count":0,"forks_count":3,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-06-03T19:58:37.210Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/didi.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","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}},"created_at":"2021-05-24T10:20:56.000Z","updated_at":"2025-03-11T10:09:22.000Z","dependencies_parsed_at":"2024-01-29T10:09:59.354Z","dependency_job_id":"34234171-fdb2-461d-ab97-9b6f443a3259","html_url":"https://github.com/didi/slime-validator","commit_stats":{"total_commits":16,"total_committers":3,"mean_commits":5.333333333333333,"dds":0.5625,"last_synced_commit":"2948dc89ba717909affb4eb1570dc47e1d7f9a20"},"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/didi/slime-validator","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/didi%2Fslime-validator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/didi%2Fslime-validator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/didi%2Fslime-validator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/didi%2Fslime-validator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/didi","download_url":"https://codeload.github.com/didi/slime-validator/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/didi%2Fslime-validator/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260016055,"owners_count":22946321,"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":"2025-06-15T17:10:59.151Z","updated_at":"2025-06-15T17:11:00.294Z","avatar_url":"https://github.com/didi.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![NPM version][npm-image]][npm-url]\n[![NPM quality][quality-image]][quality-url]\n[![npm download][download-image]][download-url]\n[![build status][travis-image]][travis-url]\n\n[travis-image]: https://travis-ci.org/didi/slime-validator.svg?branch=master\u0026status=passed\n[travis-url]: https://travis-ci.org/didi/slime-validator\n[download-image]: https://img.shields.io/npm/dm/slime-validator.svg?style=flat-square\n[download-url]: https://npmjs.org/package/slime-validator\n[npm-image]: https://img.shields.io/npm/v/slime-validator.svg?style=flat-square\n[npm-url]: https://npmjs.org/package/slime-validator\n[quality-image]: http://npm.packagequality.com/shield/slime-validator.svg?style=flat-square\n[quality-url]: http://packagequality.com/#?package=slime-validator\n[codecov-image]: https://img.shields.io/codecov/c/github/didi/slime-validator.svg?style=flat-square\n[codecov-url]: https://codecov.io/gh/didi/slime-validator\n\n# slime-validator \n`slime-validator` is a JavaScript library of validation based on `Plugin` system and make data validation be easy.\n\n# Description\n`slime-validator` make data validation with less code, save more than 20% code than others.\n\nPlugin system let you make your own validate rules very easy and complex validate rule too. Both on Browser and Nodejs.\n\n# Installation\n\n### Using npm\n```sh\n  $ npm install slime-validator -save\n```\n\n### Browser\n```js\n  \u003cscript src=\"${YOUR_PATH}/slime-validator.js\"\u003e\u003c/script\u003e\n```\n\n# Basic Usage\n\n### For es module\n```js\n  import Validator from 'slime-validator'\n\n  // One\n  const V1 = new Validator({ Required:true })\n  console.log(V1.validate('Hello world')) // Output: null\n  console.log(V1.validate()) // Output: Input is required\n\n  // Two\n  console.log(Validator.validate({ Required:true }, 'Hello world')) // Output: null\n  console.log(Validator.validate({ Required:true }, null)) // Output: Input is required\n```\n\n### For CDN\n```html\n  \u003chtml\u003e\n    \u003cscript src=\"https://unpkg.com/slime-validator@1.0.3/dist/slime-validator.umd.js\"\u003e\u003c/script\u003e\n    \u003cscript\u003e\n      let ret = null\n\n      const v = new window.SlimeValidator({\n        field: [{ MaxLength: 10 }]\n      })\n      ret = v.validate({field: '11222222221'})\n      console.log(JSON.stringify(ret))\n    \u003c/script\u003e\n    \u003cbody\u003e\n\n    \u003c/body\u003e\n  \u003c/html\u003e\n```\n\n# Custom Validation Rule\n```js\n  Validator.usePlugin({\n    tagName: 'IsNotRequired',\n    message(field, value, opts) {\n      return `${field} Check failed`\n    },\n    validate(field, value, opts) {\n      return false\n    }\n  }, true) // true means to replace the exist rule with the same name.\n\n  const V7 = new Validator({\n    field: { IsNotRequired: true }\n  })\n  console.log(V7.validate({\n    field: \"Something\"\n  })) // Output：{ field: 'field Check failed' }\n```\n\nFor more information you can read [Document](docs/index.md)\n\n# Who use?\n\u003cdiv align=\"left\"\u003e\n\u003cimg src=\"https://user-images.githubusercontent.com/9922563/219527755-11fd6fcc-cfd7-4ac3-aedb-6f37822f6dd3.png\" width=\"150\" height=\"140\"\u003e\n\u003cimg src=\"https://user-images.githubusercontent.com/9922563/219527907-c2ff23c1-47fa-448d-925a-91b1b1892b32.png\" width=\"150\" height=\"140\"\u003e\n\u003c/div\u003e\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdidi%2Fslime-validator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdidi%2Fslime-validator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdidi%2Fslime-validator/lists"}