1.1.20 • Published 3 years ago

ovt v1.1.20

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

Ovt (Object validation tool)

Build Status

Object schema description language and validator for JavaScript.

Introduction

Imagine you run facebook and you want visitors to sign up on the website with real names and not something like l337_p@nda in the first name field. How would you define the limitations of what can be inputted and validate it against the set rules?

This is ovt, ovt allows you to create blueprints or schemas for JavaScript objects (an object that stores information) to ensure validation of key information.

Example

const ovt = require('ovt');

const schema = ovt.object().keys({
    username: ovt.string().isLength(3, 30).required(),
    password: ovt.string().matches(/^[a-zA-Z0-9]{3,30}$/),
    access_token: ovt.array().items(ovt.string(), ovt.number()),
    birthyear: ovt.number().isInteger().gt(1900).lt(2013),
    email: ovt.string().isEmail(),
    login: ovt.alternatives().required().try(
      ovt.string().isEmail(),
      ovt.string().isMobilePhone('zh-CN')
    )
});

ovt.validate({
  username: 'abc',
  birthyear: 1994
}, schema, function (err, value) {
  // err === null -> valid
});

Plugins

1.1.20

3 years ago

1.1.19

4 years ago

1.1.18

4 years ago

1.1.17

4 years ago

1.1.16

5 years ago

1.1.15

5 years ago

1.1.14

6 years ago

1.1.12

7 years ago

1.1.11

7 years ago

1.1.10

7 years ago

1.1.9

7 years ago

1.1.8

7 years ago

1.1.7

7 years ago

1.1.6

7 years ago

1.1.5

7 years ago

1.1.4

7 years ago

1.1.3

7 years ago

1.1.2

7 years ago

1.1.1

7 years ago

1.1.0

7 years ago

1.0.7

8 years ago

1.0.6

8 years ago

1.0.5

8 years ago

1.0.4

8 years ago

1.0.3

8 years ago

1.0.2

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago