Skip to content

Instantly share code, notes, and snippets.

@rlidwka
Last active December 28, 2015 12:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rlidwka/7499686 to your computer and use it in GitHub Desktop.
Save rlidwka/7499686 to your computer and use it in GitHub Desktop.
var eve = require('EVE')
var type = eve.type
schema = type.object({
number: type.number().min(5),
something: type.string().trim().notEmpty().required()
})
console.log(schema.val({number:'123'}).validate())
/*
{ ok: true,
name: 'EveError',
_messages: [],
_hasChildren: true,
_children:
{ something:
{ ok: true,
name: 'EveError',
_messages: [Object],
_hasChildren: false,
_children: {},
_alias: undefined,
message: 'is required' } },
message: 'is required' }
*/
console.log(schema.val({number:'123'}).val())
/*
{ number: 123 }
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment