{"id":22561776,"url":"https://github.com/bpcloud/validation","last_synced_at":"2025-10-17T02:32:17.276Z","repository":{"id":79322753,"uuid":"371232365","full_name":"bpcloud/validation","owner":"bpcloud","description":"Data type validator","archived":false,"fork":false,"pushed_at":"2021-05-27T04:46:39.000Z","size":59,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-08-06T15:50:32.126Z","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/bpcloud.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":"2021-05-27T03:14:13.000Z","updated_at":"2021-05-27T04:46:41.000Z","dependencies_parsed_at":"2023-04-10T03:01:56.301Z","dependency_job_id":null,"html_url":"https://github.com/bpcloud/validation","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/bpcloud/validation","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bpcloud%2Fvalidation","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bpcloud%2Fvalidation/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bpcloud%2Fvalidation/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bpcloud%2Fvalidation/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bpcloud","download_url":"https://codeload.github.com/bpcloud/validation/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bpcloud%2Fvalidation/sbom","scorecard":{"id":249697,"data":{"date":"2025-08-11","repo":{"name":"github.com/bpcloud/validation","commit":"f604b6824386aa027b5d61094c2684257eb435d2"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3,"checks":[{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Code-Review","score":0,"reason":"Found 0/2 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}}]},"last_synced_at":"2025-08-17T08:13:13.724Z","repository_id":79322753,"created_at":"2025-08-17T08:13:13.724Z","updated_at":"2025-08-17T08:13:13.724Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":271722192,"owners_count":24809660,"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","status":"online","status_checked_at":"2025-08-22T02:00:08.480Z","response_time":65,"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":[],"created_at":"2024-12-07T22:09:44.988Z","updated_at":"2025-10-17T02:32:12.241Z","avatar_url":"https://github.com/bpcloud.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\nSome typescript decorators, like spring-validation and so on.\n\n- [Setup](#setup)\n- [Example](#example)\n- [like java spring validation](#like-java-spring-validation)\n  - [Null value validator](#null-value-validator)\n  - [Boolean validator](#boolean-validator)\n  - [Number validator](#number-validator)\n  - [String validator](#string-validator)\n  - [Time validator](#time-validator)\n- [Enum validator](#enum-validator)\n- [Type validator](#type-validator)\n- [Custom validator](#custom-validator)\n\n## Setup\n\n```\nnpm i @bpframework/validation\n```\n\nset config in tsconfig.json\n\n```\n\"experimentalDecorators\": true,\n\"emitDecoratorMetadata\": true,\n```\n\n## Example\n\n```js\nimport {NotNull, Type} from '@bpframework/validation';\n\nclass BeanA {\n  @NotNull\n  @Type.Boolean\n  a: boolean = null;\n}\n\n// will throw a exception: \n//  - febs.exception('message', febs.exception.PARAM, __filename, __line, __column);\nlet obj = new BeanA();\n\n// will throw a exception\nobj.a = null;\nobj.a = undefined;\n```\n\n**!!!WARNING: The following code does not trigger a validity check**\n\n```js\nclass BeanA {\n  @NotNull\n  a: boolean;\n}\n\n// No exception is thrown.\nlet obj = new BeanA();\n\n// Will throw a exception (trigger by settter)\nobj.a = null;\n```\n\n\u003e **\u003cfont color=#ff0000\u003eAll validate decorators have a corresponding array validation method\u003cbr\u003e, e.g. `@Max.List` use to validator array\u003c/font\u003e**\n\n## like java spring validation\n\n### Null value validator\n\n| 名称                              | 作用                                                                                             | 例子                                  |\n| --------------------------------- | ------------------------------------------------------------------------------------------------ | ------------------------------------- |\n| `@Null`                           | must be null or undefined.                                                                       | @Null({message: \"must is null\"})      |\n| `@NotNull`                        | cannot be null or undefined.                                                                     | @NotNull({message: \"cannot be null\"}) |\n| `@NotBlank`                       | must contain a non-null char\u003cbr\u003e trim(str).length\u003e0                                              | @NotBlank                             |\n| `@NotEmpty`                       | cannot be null or undefined, and the length is greater then 0\u003cbr\u003e (o.size() \u003e 0 或 o.length \u003e 0) | @NotEmpty                             |\n| `@Size`({max:number, min:number}) | check the length of a string or array\u003cbr\u003e (o.size() 或 o.length)                                 | \u0026nbsp;                                |\n\n### Boolean validator\n\n| 名称           | 作用          | 例子                                     |\n| -------------- | ------------- | ---------------------------------------- |\n| `@AssertFalse` | must be false | @AssertFalse({message: \"must be false\"}) |\n| `@AssertTrue`  | muse be true  | @AssertTrue({message: \"muse be true\"})   |\n\n### Number validator\n\n| 名称                                                         | 作用                                                                | 例子                                        |\n| ------------------------------------------------------------ | ------------------------------------------------------------------- | ------------------------------------------- |\n| `@DecimalMax`({value:number \u0026brvbar; string})                | Number value must be less than or equal to the specified value      | @DecimalMax({value:1000, message: \"error\"}) |\n| `@DecimalMin`({value:number \u0026brvbar; string})                | Number value must be greater than or equal to the specified value   | @DecimalMin({value:0, message: \"error\"})    |\n| `@Max`({value:number \u0026brvbar; string})                       | Integer value must be less than or equal to the specified value.    | @Max({value:1000, message: \"error\"})        |\n| `@Min`({value:number \u0026brvbar; string})                       | Integer value must be greater than or equal to the specified value. | @Min({value:1000, message: \"error\"})        |\n| [unsupported] ~~@Digits({integer:number, fraction:number})~~ | unsupported                                                         | @Digits({integer:5, fraction:1})            |\n| `@Negative`                                                  | Number value must be negative                                       | \u0026nbsp;                                      |\n| `@NegativeOrZero`                                            | Number value must be negative or zero                               | \u0026nbsp;                                      |\n| `@Positive`                                                  | Number value must be positive                                       | \u0026nbsp;                                      |\n| `@PositiveOrZero`                                            | Number value must be positive or zero                               | \u0026nbsp;                                      |\n| `@Range`({min:number=0, max:number})                         | check the range of number value                                     | \u0026nbsp;                                      |\n\n\n### String validator\n\n| 名称                        | 作用                                                            | 例子                    |\n| --------------------------- | --------------------------------------------------------------- | ----------------------- |\n| `@Email`({regexp:RegExp})   | Whether the specified value is Email. You can specify a regular | @Email({regexp:/.*/})   |\n| `@Pattern`({regexp:RegExp}) | Whether the specified value matches regular                     | @Pattern({regexp:/.*/}) |\n\n\n### Time validator\n\n| 名称               | 作用                         | 例子   |\n| ------------------ | ---------------------------- | ------ |\n| `@Future`          | Date value is the future time       | \u0026nbsp; |\n| `@FutureOrPresent` | Date value is the future time or now | \u0026nbsp; |\n| `@Past`            | Date value is the past time       | \u0026nbsp; |\n| `@PastOrPresent`   | Date value is the past time or now | \u0026nbsp; |\n\n## Enum validator\n\n| 名称                                 | 作用                            |\n| ------------------------------------ | ------------------------------- |\n| `@Enum`({allows: [v1, v2, v3, ...]}) | Verify the value is one of the allowed values.   |\n| `@Type.Enum`({enumType: EnumName})   | Verify the value is enum type. |\n\n`@Type.Enum` example:\n\n```js\nimport {Type} from '@bpframework/validation';\n\nenum Enum1 {\n  a = '2323',\n  b = 'xxxx'\n}\n\nclass BeanA {\n  @Type.Enum({enumType: Enum1 })\n  a: any = null;\n}\nlet obj = new BeanA();\n\nobj.a = Enum1.a;  // ok.\nobj.a = Enum1.b;  // ok.\nobj.a = 1;  // will throw a exception.\n```\n\n## Type validator\n\n| 名称            | 作用                     |\n| --------------- | ------------------------ |\n| `@Type.Boolean` | Verify that the value is a Boolean. |\n| `@Type.Number`  | Verify that the value is a Number.      |\n| `@Type.Integer` | Verify that the value is a Integer.  |\n| `@Type.BigInt`  | Verify that the value is a Big-Integer.    |\n| `@Type.String`  | Verify that the value is a String.    |\n| `@Type.Date`    | Verify that the value is a Date or Date-string.      |\n| `@Type.Object`  | Verify that the value is a Object.    |\n| `@Type.Array`   | Verify that the value is a Array.      |\n\n## Custom validator\n\n| 名称              | 作用          |\n| ----------------- | ------------- |\n| `@Type.Validator` | Custom validator. |\n\n\n```js\n// validator value == 1\n@Type.Validator({\n  checkCB(value:any) {\n    if (value !== 1) return false;\n  }\n})\nvalue: number;\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbpcloud%2Fvalidation","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbpcloud%2Fvalidation","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbpcloud%2Fvalidation/lists"}