![Introducing Enhanced Alert Actions and Triage Functionality](https://cdn.sanity.io/images/cgdhsj6q/production/fe71306d515f85de6139b46745ea7180362324f0-2530x946.png?w=800&fit=max&auto=format)
Product
Introducing Enhanced Alert Actions and Triage Functionality
Socket now supports four distinct alert actions instead of the previous two, and alert triaging allows users to override the actions taken for all individual alerts.
props-check
Advanced tools
Readme
Check your props and give a helpful error if you've mis-typed.
npm install props-check
const PropsCheck = require('props-check')
PropsCheck
PropsCheck checks props against the spec and returns a map with list of possible corrections.
// Example spec
const spec = {
read: 'Function'
, sanitize: '[Function]'
, validate: '[Function]'
, normalize: '[Function]'
};
// Example object
const test = {
raed: () => null
, santize: [ () => null ]
, alvidate: [ () => null ]
, normalize: [ () => null ]
, format: [ () => null ]
};
const result = PropsCheck(spec, test);
result:
{ raed: [ 'read' ]
, santize: [ 'sanitize' ]
, alvidate: [ 'validate' ]
, normalize: []
, format: []
}
PropsCheck
returns null
if spec and test have the exact same props.
PropsCheck.custom
PropsCheck.custom
takes a custom comparator and returns a function that is similar to PropsCheck.
const comparator = (a, b) => a < b;
const result = PropsCheck.custom(comparator)(spec, test);
PropsCheck.human
PropsCheck.human
accepts the same arguments as PropsCheck but returns a more helpful error message.
const result = PropsCheck.human(spec, test);
result:
You gave me this:
{
raed: …,
santize: …,
alvidate: …,
normalize: …
}
I wasn't expecting:
{ raed: …, santize: …, alvidate: … }
You didn't give me:
{ read: …, sanitize: …, validate: … }
Here's how to fix it:
raed <-> read
santize <-> sanitize
alvidate <-> validate
I have no idea what this mean:
{ format: …, }
PropsCheck.customHuman
PropsCheck.customHuman
takes a custom message map and returns a function that is similar to PropsCheck.human.
const customMessages = {
given: [ "This is what I got:", … ]
, unexpected: [ "Something is not right..", … ]
, missing: [ "I'm looking for this:", … ]
, conclusion: [ "I suggest the following changes:", … ]
, clueless: [ "I have no idea what these are:", … ]
};
const result = PropsCheck.customHuman(customMessages)(spec, test);
Custom messages will be used randomly if more than 1 message is provided in the list. If a property of the customMessages is misspelled or if a list is empty, default messages will be used instead.
PropsCheck.custom
and provide your own comparator, make sure that the comparator accepts 2 arguments and returns either 0
on equal, 1
on similar, or -1
on mismatch.PropsCheck(spec)(test);
PropsCheck.custom(comparator)(spec)(test);
PropsCheck.human(spec)(test);
PropsCheck.customHuman(customMessages)(spec)(test);
are the same as:
PropsCheck(spec, test);
PropsCheck.custom(comparator)(spec, test);
PropsCheck.human(spec, test);
PropsCheck.customHuman(customMessages)(spec, test);
FAQs
Check your props and give a helpful error if you've mis-typed.
The npm package props-check receives a total of 1 weekly downloads. As such, props-check popularity was classified as not popular.
We found that props-check demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket now supports four distinct alert actions instead of the previous two, and alert triaging allows users to override the actions taken for all individual alerts.
Security News
Polyfill.io has been serving malware for months via its CDN, after the project's open source maintainer sold the service to a company based in China.
Security News
OpenSSF is warning open source maintainers to stay vigilant against reputation farming on GitHub, where users artificially inflate their status by manipulating interactions on closed issues and PRs.