1.2.4 • Published 7 years ago

imm-validate v1.2.4

Weekly downloads
-
License
ISC
Repository
-
Last release
7 years ago

a forgiving validator/formatter

You could use this to power a schema-powered form library or anything where you want to validate/format values are arbitrary levels of nesting.

Smallest Example possible:

const {validate} = require('imm-validate');
// define schema 'shape' (types not used yet)
const schema = {
    name: "string"
}

// define options for each key in schema
const options = {
    name: {
        validators: [
            function alwaysFalse() {
                return false
            }
        ]
    }
}

// tracked values 
const values = {name: "shane"}

// convenience the tracked values against the schema/options
const result = validate(schema, options, values);

/**
 * result.fields     <- with errors at each level
 * result.error      <- all errors collated
 * result.hasErrors  <- convienience
 * result.singularErrors  <- only show first error from each property (useful
 *                           if you have multiple validators)
 */
1.2.4

7 years ago

1.2.3

7 years ago

1.2.2

7 years ago

1.2.1

7 years ago

1.2.0

7 years ago

1.1.2

7 years ago

1.1.1

7 years ago

1.1.0

7 years ago

1.0.5

7 years ago

1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago