Security News
Introducing the Socket Python SDK
The initial version of the Socket Python SDK is now on PyPI, enabling developers to more easily interact with the Socket REST API in Python projects.
Runtime type-checking for JavaScript.
$ npm install rttc --save
null
is never allowed.NaN
is never allowed.Infinity
is never allowed.-Infinity
is never allowed.The usage of this module is changing, but backwards compatibility will be maintained up until the first major version bump (v1.0.0). See tests for more details.
Validate and/or coerce a set of input values against a set of expectations (defined as input definitions.)
Two options may be provided:
coerce
- before failing, attempt to coerce not-quite-right input values to their expected type.base
- if an input value is missing, fill in its place in the result to the "base type" (falsy value)require('rttc').rttc({
foo: {
type: 'string',
required: true
},
bar: {
type: { baz: {name: 'string'} },
required: false
}
}, {
foo: 'hi',
bar: {
baz: {
name: 'Rick'
}
}
});
Infer the type/schema of the provided value.
require('rttc').infer(false);
// => 'boolean'
require('rttc').infer(0);
// => 'number'
require('rttc').infer({
foo: 'bar'
});
// => { foo: 'string' }
require('rttc').infer({
foo: 'whatever',
bar: { baz: true }
});
// => { foo: 'string', bar: { baz: 'boolean' } }
require('rttc').infer([{
foo: ['bar']
}]);
// => [{ foo: ['string'] }]
require('rttc').infer({
user: {
friends: [{
name: 'Lenny',
age: 77
}]
});
// =>
/*
{
user: {
friends: [{
name: 'Lenny',
age: 77
}]
}
*/
require('rttc').types;
// =>
/*
{ nan: { is: [Function: isNaN], to: [Function] },
null: { is: [Function: isNull], to: [Function] },
undefined:
{ is: [Function: isUndefined],
to: [Function] },
bool:
{ is: [Function: isBoolean],
to: [Function],
base: false },
defined: { is: [Function], to: [Function] },
int:
{ is: [Function],
to: [Function],
base: 0 },
str:
{ is: [Function: isString],
to: [Function],
base: '' },
obj: { is: [Function], to: [Function], base: {} },
arr:
{ is: [Function: isArray],
to: [Function],
base: [] },
date:
{ is: [Function: isDate],
to: [Function],
base: Tue Jan 13 2015 08:58:29 GMT-0800 (PST) },
number:
{ is: [Function],
to: [Function],
base: 0 },
url:
{ is: [Function: isString],
to: [Function],
base: '' },
email:
{ is: [Function: isString],
to: [Function],
base: '' },
string:
{ is: [Function: isString],
to: [Function],
base: '' },
boolean:
{ is: [Function: isBoolean],
to: [Function],
base: false },
integer:
{ is: [Function],
to: [Function],
base: 0 },
float:
{ is: [Function],
to: [Function],
base: 0 } }
*/
FAQs
Runtime type-checking for JavaScript.
The npm package rttc receives a total of 88,425 weekly downloads. As such, rttc popularity was classified as popular.
We found that rttc demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers 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.
Security News
The initial version of the Socket Python SDK is now on PyPI, enabling developers to more easily interact with the Socket REST API in Python projects.
Security News
Floating dependency ranges in npm can introduce instability and security risks into your project by allowing unverified or incompatible versions to be installed automatically, leading to unpredictable behavior and potential conflicts.
Security News
A new Rust RFC proposes "Trusted Publishing" for Crates.io, introducing short-lived access tokens via OIDC to improve security and reduce risks associated with long-lived API tokens.