ov

0.1.1 • Public • Published

ov logo

ov

ov is a object validation library which can be used in the browser or with nodejs

npm version license

Installation

$ npm install --save ov

Usage

NodeJS

import { ov, Model, Blueprint } from 'ov';
 
const a = {
  name: 'Sean_',
  age: 19,
};
 
const b = new Blueprint({
  name: new Model()
    .string()
    .max(25)
    .alphanumeric(),
  age: new Model()
    .number()
    .integer()
    .min(16),
});
 
console.log('Valid', ov.validate(a, b));

Output

Valid Result {
  valid: false,
  errors:
   [ ValidationError {
       message: '\'name\' can only contain a-z, A-Z and 0-9',
       path: 'name',
       value: 'Sean_',
       model: [StringModel],
       check: [Check] } ] }

Browser

index.html

<script src="./dist/ov.js"></script>

script.js

const { ov, Model, Blueprint } = OV;
 
const a = {
  name: 'Sean_',
  age: 19,
};
 
const b = new Blueprint({
  name: new Model()
    .string()
    .max(25)
    .alphanumeric(),
  age: new Model()
    .number()
    .integer()
    .min(16),
});
 
console.log('Valid', ov.validate(a, b));

Output

Valid Result {
  valid: false,
  errors:
   [ ValidationError {
       message: '\'name\' can only contain a-z, A-Z and 0-9',
       path: 'name',
       value: 'Sean_',
       model: [StringModel],
       check: [Check] } ] }

Readme

Keywords

Package Sidebar

Install

npm i ov

Weekly Downloads

1

Version

0.1.1

License

MIT

Unpacked Size

79.7 kB

Total Files

26

Last publish

Collaborators

  • hammy2899