TGOlson / o-validator

Flexible and lightweight object validation library.
13 stars 1 forks source link

Validate function arguments #3

Open TGOlson opened 9 years ago

TGOlson commented 9 years ago

More or less a simple contract system. AKA, make validators work on arrays.

var validatedFunction = V.validateArgs([isString, isNumber], function(str, n) {
  // ...
})
TGOlson commented 9 years ago

Works: need to test and prettify errors.

var validateArgs = R.curry(function(schema, f) {
  return function() {
    return f.apply(null, V.validateOrThrow(schema, arguments));
  };
});