Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@toolz/allow

Package Overview
Dependencies
Maintainers
1
Versions
32
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@toolz/allow - npm Package Compare versions

Comparing version 0.0.10 to 0.0.11

2

package.json
{
"name": "@toolz/allow",
"version": "0.0.10",
"version": "0.0.11",
"description": "Provides validation of data types",

@@ -5,0 +5,0 @@ "keywords": [

@@ -29,3 +29,3 @@ # allow

### aBoolean
### .aBoolean()

@@ -44,3 +44,3 @@ ```javascript

### aFunction
### .aFunction()

@@ -51,3 +51,6 @@ ```javascript

/*
This will fail unless a function is provided as the value for callback
This will fail unless a function is provided as the value for callback.
It doesn't care what's inside the function. It can even be blank, like:
() => {}
But it must be a function of some kind.
*/

@@ -57,3 +60,3 @@ }

### anArray
### .anArray()

@@ -65,4 +68,6 @@ ```javascript

This will fail unless an array is provided as the value for theValues.
In this example, theValues can be an empty array - but it must still
be an array.
The check doesn't examine the contents of the array. It can be an
empty array, like:
[]
But it must be an array of some kind.
*/

@@ -87,3 +92,3 @@ }

/*
This ensures that theValues is an array, that is has no fewer than 2
This ensures that theValues is an array, that has no fewer than 2
elements, and no more than 50 elements.

@@ -94,3 +99,3 @@ */

### anArrayOfArrays
### .anArrayOfArrays()

@@ -103,5 +108,6 @@ ```javascript

nestedArray. It will also fail if any of elements inside nestedArray
are not also arrays. If you need something that will ensure that the
array, INSIDE the array, also contains more arrays, you need to get a
life and publish your own damn NPM package.
are not also arrays. It does not inspect the contents of the arrays
inside nestedArray. They can be empty arrays, like:
[[], [], []]
But they must be arrays of some kind.
*/

@@ -127,3 +133,3 @@ }

This ensures that nestedArray is an array, that all of its elements
are arrays, that is has no fewer than 2 elements, and no more than 50
are arrays, that it has no fewer than 2 elements, and no more than 50
elements .

@@ -133,1 +139,131 @@ */

```
### .anArrayOfInstances()
```javascript
const person = {
firstName: '',
lastName: '',
middleInitial: '',
}
const doSomething = people => {
allow.anArrayOfInstances(people, person);
/*
This will fail unless an array is provided as the value for
people. It will also fail if any of the elements inside people are
not objects, and if those objects do not have all the keys present
in the model object (in this case: person). It does not inspect the
types of data held in those keys, and it will allow additional keys
that do not exist in the model object. But it expects every object
in the array to have all of the keys present in the model.
*/
}
```
```javascript
const person = {
firstName: '',
lastName: '',
middleInitial: '',
}
const doSomething = people => {
allow.anArrayOfInstances(people, person, 0);
/*
The third argument of anArrayOfInstances() is the minimum length of
the array. So, by setting this value to 0, it ensures that people is
a non-empty array of "person" instances.
*/
}
```
```javascript
const person = {
firstName: '',
lastName: '',
middleInitial: '',
}
const doSomething = people => {
allow.anArrayOfInstances(people, person, 2, 50);
/*
This ensures that people is an array of "person" instances, that it has
no fewer than 2 elements, and no more than 50 elements .
*/
}
```
### .anArrayOfIntegers()
```javascript
const doSomething = theNumbers => {
allow.anArrayOfIntegers(theNumbers);
/*
This will fail unless an array is provided as the value for
theNumbers. It will also fail if any of elements inside theNumbers
are not also integers. This means that it will fail on any non-numeric
value, and it will also fail on any number that is not a "whole"
number. It will accept decimal values, as long as those decimals
evaluate to a whole number. So this works:
[1.0, 3.00, 42.0]
But this does not:
[1.0, 3.14, 42.0]
*/
}
```
```javascript
const doSomething = theNumbers => {
allow.anArrayOfIntegers(theNumbers, 0);
/*
The second argument of anArrayOfIntegers() is the minimum length of
the array. So, by setting this value to 0, it ensures that theNumbers is
a non-empty array of integers.
*/
}
```
```javascript
const doSomething = theNumbers => {
allow.anArrayOfIntegers(theNumbers, 2, 50);
/*
This ensures that theNumbers is an array of integers, that it has no
fewer than 2 elements, and no more than 50 elements .
*/
}
```
### .anArrayOfNumbers()
```javascript
const doSomething = theNumbers => {
allow.anArrayOfNumbers(theNumbers);
/*
This will fail unless an array is provided as the value for
theNumbers. It will also fail if any of elements inside theNumbers
are not also numbers.
*/
}
```
```javascript
const doSomething = theNumbers => {
allow.anArrayOfNumbers(theNumbers, 0);
/*
The third argument of anArrayOfNumbers() is the minimum length of
the array. So, by setting this value to 0, it ensures that theNumbers is
a non-empty array of integers.
*/
}
```
```javascript
const doSomething = theNumbers => {
allow.anArrayOfNumbers(theNumbers, 2, 50);
/*
This ensures that theNumbers is an array of integers, that it has no
fewer than 2 elements, and no more than 50 elements .
*/
}
```
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc