0.0.21 • Published 4 years ago

eclesi-schema-assert v0.0.21

Weekly downloads
-
License
MIT
Repository
github
Last release
4 years ago

Eclesi Schema Assert

This library provide an easy and extensible api to create schema validator for input or single values.

const schema = Assert.strict({
  name: Assert.required().string(),
  email: Assert.required().email(),
  password: Assert.required().string().lengthMinimum(8)
})

// For a valid input the schema validation will return undefined because no violations was found
schema.validate({
  name: 'Alef',
  email: 'any@email.com',
  password: 's3cr3tp4ssw0rd'
})

// For a invalid input the schema validation will return an object containing each violation for each property
schema.validate({})
/**
 * {
 *    schema: ['strict_type_mismatch'],
 *    name: ['required', 'string_type_mismatch'],
 *    email: ['required', 'email_type_mismatch'],
 *    password: ['required', 'string_type_mismatch', 'length_out_of_minimum']
 *  }
 */
0.0.21

4 years ago

0.0.20

4 years ago

0.0.19

4 years ago

0.0.18

4 years ago

0.0.17

4 years ago

0.0.16

4 years ago

0.0.15

4 years ago

0.0.14

4 years ago

0.0.13

4 years ago

0.0.12

4 years ago

0.0.11

4 years ago

0.0.10

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

0.0.2

4 years ago

0.0.1

4 years ago