0.0.21 • Published 3 years ago

eclesi-schema-assert v0.0.21

Weekly downloads
-
License
MIT
Repository
github
Last release
3 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

3 years ago

0.0.20

3 years ago

0.0.19

3 years ago

0.0.18

3 years ago

0.0.17

3 years ago

0.0.16

3 years ago

0.0.15

3 years ago

0.0.14

3 years ago

0.0.13

3 years ago

0.0.12

3 years ago

0.0.11

3 years ago

0.0.10

3 years ago

0.0.9

3 years ago

0.0.8

3 years ago

0.0.7

3 years ago

0.0.6

3 years ago

0.0.5

3 years ago

0.0.4

3 years ago

0.0.3

3 years ago

0.0.2

3 years ago

0.0.1

3 years ago