Class: NotNode

NotNode

new NotNode(){NotNode}

The NotNode class represents a validation where the value must fail all included validation nodes

Returns:
NotNode instance.

Methods

addValidations(validations){NotNode}

Add all validation node that must fail for this node to be valid

Name Type Description
validations array

all validation node that must fail for this node to be valid

Example
// Create a Not validator for string validations

assert = require('assert'),
  Compiler = require('vitesse').Compiler,
  StringNode = require('vitesse').StringNode,
  IntegerNode = require('vitesse').IntegerNode,
  NotNode = require('vitesse').NotNode;

var string1 = new StringNode(null, null, {typeCheck:true})
  .addValidation({$gte: 5, $lte: 100});

var integer1 = new IntegerNode(null, null, {typeCheck:true})
  .addValidation({$gte: 100, $lte: 1000});

var schema = new NotNode()
  .addValidations([string1, integer1]);

var compiler = new Compiler({});
// Compile the AST
var func = compiler.compile(schema, {});

// Validate {}
var results = func.validate(400);
assert.equal(1, results.length);
assert.equal("value failed not rule", results[0].message);
assert.deepEqual(['object'], results[0].path);
assert.ok(results[0].rule === schema);

// Validate string 'xxxxxx'
var results = func.validate(50);
assert.equal(0, results.length);

generate(context)

Generate the code for this node

Name Type Description
context object

the generation context for this node

path(){array}

Return the current object path

Returns:
array containing the path to this node

setTypeCheck(typeCheck){NotNode}

Type check value

Name Type Description
typeCheck boolean

type check value

comments powered by Disqus