0.0.21 • Published 2 years ago

eclesi-schema-assert v0.0.21

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

2 years ago

0.0.20

2 years ago

0.0.19

2 years ago

0.0.18

2 years ago

0.0.17

2 years ago

0.0.16

2 years ago

0.0.15

2 years ago

0.0.14

2 years ago

0.0.13

2 years ago

0.0.12

2 years ago

0.0.11

2 years ago

0.0.10

2 years ago

0.0.9

2 years ago

0.0.8

2 years ago

0.0.7

2 years ago

0.0.6

2 years ago

0.0.5

2 years ago

0.0.4

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago