Installations
npm install @alifd/validate
Developer Guide
Typescript
No
Module System
CommonJS
Node Version
14.17.1
NPM Version
7.20.2
Score
76.2
Supply Chain
95.9
Quality
85.3
Maintenance
100
Vulnerability
100
License
Releases
Contributors
Unable to fetch Contributors
Languages
TypeScript (99.36%)
JavaScript (0.64%)
Developer
alibaba-fusion
Download Statistics
Total Downloads
848,938
Last Day
172
Last Week
1,179
Last Month
8,268
Last Year
127,515
GitHub Statistics
1 Stars
82 Commits
3 Forks
3 Watching
27 Branches
11 Contributors
Bundle Size
14.70 kB
Minified
3.90 kB
Minified + Gzipped
Package Meta Information
Latest Version
1.4.0
Package Id
@alifd/validate@1.4.0
Unpacked Size
95.76 kB
Size
24.45 kB
File Count
19
NPM Version
7.20.2
Node Version
14.17.1
Total Downloads
Cumulative downloads
Total Downloads
848,938
Last day
-56.9%
172
Compared to previous day
Last week
-57.6%
1,179
Compared to previous week
Last month
2.3%
8,268
Compared to previous month
Last year
-48.4%
127,515
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dev Dependencies
22
Validate
Validation to be used with @alifd/field
Install with npm install @alifd/validate
Basic Usage
Callback
const rules = {
myInput: function (rule, value, cb, options) {
if (value <= 100) {
cb('Value must be more than 100');
} else {
cb();
}
}
}
const validator = new Validator(rules);
validator.validate({ myInput: 90 }, (err) => { console.log(err)});
Promise
const rules = {
myInput: function (rule, value, cb, options) {
if (value <= 100) {
cb('Value must be more than 100');
} else {
cb();
}
}
}
const validator = new Validator(rules);
validator.validatePromise({ myInput: 90 })
.then((err) => { console.log(err)})
API
Initialization
let validator = new Validator(rules [, options]);
Parameter | Description | Type | Optional | Default |
---|---|---|---|---|
rules | Map of rule names to validation functions | { [ruleName] : Array of validation functions } | yes | undefined |
options | validation options | Object | yes | {} |
options
configuration item
Parameters | Description | Type | Default |
---|---|---|---|
first | should only return the first error found amongst rules | Boolean | undefined |
messages | map to override default messages | Object | (see ./src/messages) |
Development
Testing
npm run test
- triggers a one-time full run of all unit tests
npm run test-watch
- triggers a run of all unit tests, but watches for any changes to code or tests and reruns all tests.
Making commits
Commits must be in the following format TYPE(SCOPE): MESSAGE
, where SCOPE
is optional.
e.g. fix: validatePromise return value
Review the commitlint.config.js
file to see allowed types.
Release
There 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.
Travis 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.
NOTE: the package.json file needs to be updated manually after the release.
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
- Info: project has a license file: LICENSE:0
- Info: FSF or OSI recognized license: MIT License: LICENSE:0
Reason
Found 4/16 approved changesets -- score normalized to 2
Reason
dependency not pinned by hash detected -- score normalized to 2
Details
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/test.yml:9: update your workflow using https://app.stepsecurity.io/secureworkflow/alibaba-fusion/validate/test.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/test.yml:11: update your workflow using https://app.stepsecurity.io/secureworkflow/alibaba-fusion/validate/test.yml/master?enable=pin
- Warn: downloadThenRun not pinned by hash: .github/workflows/test.yml:22
- Info: 0 out of 2 GitHub-owned GitHubAction dependencies pinned
- Info: 1 out of 1 npmCommand dependencies pinned
- Info: 0 out of 1 downloadThenRun dependencies pinned
Reason
detected GitHub workflow tokens with excessive permissions
Details
- Warn: no topLevel permission defined: .github/workflows/test.yml:1
- Info: no jobLevel write permissions found
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
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
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 21 are checked with a SAST tool
Reason
22 existing vulnerabilities detected
Details
- Warn: Project is vulnerable to: GHSA-93q8-gq69-wqmw
- Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg
- Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275
- Warn: Project is vulnerable to: GHSA-ff7x-qrg7-qggm
- Warn: Project is vulnerable to: GHSA-rc47-6667-2j5j
- Warn: Project is vulnerable to: GHSA-78xj-cgh5-2h22
- Warn: Project is vulnerable to: GHSA-2p57-rm9w-gvfp
- Warn: Project is vulnerable to: GHSA-896r-f27r-55mw
- Warn: Project is vulnerable to: GHSA-5v2h-r2cx-5xgj
- Warn: Project is vulnerable to: GHSA-rrrm-qjm4-v8hf
- Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv
- Warn: Project is vulnerable to: GHSA-f8q6-p94x-37v3
- Warn: Project is vulnerable to: GHSA-hj9c-8jmm-8c52
- Warn: Project is vulnerable to: GHSA-9wv6-86v2-598j
- Warn: Project is vulnerable to: GHSA-hrpp-h998-j3pp
- Warn: Project is vulnerable to: GHSA-p8p7-x288-28g6
- Warn: Project is vulnerable to: GHSA-x2pg-mjhr-2m5x
- Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw
- Warn: Project is vulnerable to: GHSA-f5x3-32g6-xq36
- Warn: Project is vulnerable to: GHSA-72xf-g2v4-qvf3
- Warn: Project is vulnerable to: GHSA-7p7h-4mm5-852v
- Warn: Project is vulnerable to: GHSA-p9pc-299p-vxgp
Score
3.1
/10
Last Scanned on 2025-01-27
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More