Baggz/Amanda — Issue #34: validates validator for amanda :P
Author: Tapsi
Created: 2012-03-04 12:24:37+00:00
State: open

Often I have a situation in a game, that a schema will be used by different other schemas. Like a position will be used by an unit, in a move way and so on. I know you can validate the object with more than one schema or simply write the conditions into every schema. But both for me is like an anti pattern and not update friendly...
So I wrote a validator and want to share it with you, because I think it could be useful for the standard distribution as well.

var amanda = require('./../lib/amanda.js');

amanda.addValidator('validates',function(property, propertyValue, validator, propertyValidators, callback) {

if( typeof validator === 'array' ){
// if validator value is an array then try to validate all schemas
for( var i=0,e=validator.length; i