2.2.0 • Published 10 months ago

data-passthrough-filter v2.2.0

Weekly downloads
6
License
MIT
Repository
github
Last release
10 months ago

Data Passthrough Filter 2.2.0

Basic usage

import { validate } from 'data-passthroug-filter';

// Incoming data (data can be object or array of objects)
const data = {
  email: 'twan@email.com',
  password: 123,
};

// Global options
const options = { overflow: false };

// Instance returns the data set with our schema and options
const val = validate(data, (e) => {
  email: e().string().required(),
  password: e().number().required(),
}, options);

Schema

We create the schema on the second argument, and it returns the schema functions we can use by chaining them like this e().number().require().

ParametervaluedefaultDescription
type()string, number, boolean, object, arraynoneSet for a specific type
nullable()booleantruenullable applied (NaN included)
length(){ min: number, max: number } or array [min, max]noneset a min and/or max length of the value
required()booleantruerequire key

Options

Additional options for validating your data

ParametervaluedefaultDescription
requiredAllbooleanfalseAll the schema keys are required
overflowbooleantrueOnly returns data that is in the schema

Errors

It will throw errors when it fails to validate (Pretty straight forward)

example: [ { key: 'password', reason: 'password is required'}]

About

If you have any questions, You can contact me on:

Twitter: @TwanLuttik

2.2.0

10 months ago

2.1.2

12 months ago

2.1.1

3 years ago

2.1.0

3 years ago

2.0.1

3 years ago

2.0.0

3 years ago

2.0.0-beta.8

3 years ago

2.0.0-beta.7

3 years ago

2.0.0-beta.6

3 years ago

2.0.0-beta.2

3 years ago

2.0.0-beta.1

3 years ago

2.0.0-beta.5

3 years ago

2.0.0-beta.4

3 years ago

2.0.0-beta.3

3 years ago

2.0.0-beta.0

3 years ago

1.2.7

3 years ago

1.2.6

3 years ago

1.2.5

3 years ago

1.2.4

3 years ago

1.2.3

3 years ago

1.2.2

3 years ago

1.2.1

3 years ago

1.2.0

3 years ago

1.1.1

3 years ago

1.1.0

3 years ago

1.0.11

4 years ago

1.0.9

4 years ago

1.0.10

4 years ago

1.0.8

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago

0.1.2

4 years ago

0.1.3

4 years ago

0.1.1

4 years ago

0.0.13

4 years ago

0.1.0

4 years ago

0.0.12

4 years ago

0.0.10

4 years ago

0.0.11

4 years ago

0.0.9

4 years ago

0.0.8

4 years ago

0.0.7

4 years ago

0.0.6

4 years ago

0.0.5

4 years ago

0.0.4

4 years ago

0.0.3

4 years ago