Esempio n. 1
0
 array: function (s) {
   if (s.hasOwnProperty('items')) {
     var items = s.items;
     if (Obj.is(items)) {
       return t.list(transform(s.items));
     }
     return t.tuple(items.map(transform));
   }
   var predicate;
   if (s.hasOwnProperty('minItems')) {
     predicate = and(predicate, fcomb.minLength(s.minItems));
   }
   if (s.hasOwnProperty('maxItems')) {
     predicate = and(predicate, fcomb.maxLength(s.maxItems));
   }
   return predicate ? subtype(Arr, predicate) : Arr;
 },
Esempio n. 2
0
 string: function (s) {
   if (s.hasOwnProperty('enum')) {
     return enums.of(s['enum']);
   }
   var predicate;
   if (s.hasOwnProperty('minLength')) {
     predicate = and(predicate, fcomb.minLength(s.minLength));
   }
   if (s.hasOwnProperty('maxLength')) {
     predicate = and(predicate, fcomb.maxLength(s.maxLength));
   }
   if (s.hasOwnProperty('pattern')) {
     predicate = and(predicate, fcomb.regexp(new RegExp(s.pattern)));
   }
   if (s.hasOwnProperty('format')) {
     t.assert(formats.hasOwnProperty(s.format), 'missing format %s, use the `registerFormat` API', s.format);
     predicate = and(predicate, formats[s.format]);
   }
   return predicate ? subtype(Str, predicate) : Str;
 },