Skip to content

v0.5.0

Compare
Choose a tag to compare
@busypeoples busypeoples released this 16 Jul 16:07
· 20 commits to master since this release

Spected handles any array input now. (See #85)
The input can be
{ values: ['a', 'b'] } or
{ values: [{a: 1}, {a: 2}] } or
{ values: [1, 'a', {a: 1}] }.
Spected runs any array input against a given spec. This also means that the defined predicates have to know how to handle the given input.

const userSpec = [
  [ 
    items => all(isLengthGreaterThan(5), items), 
    'Every item must have have at least 6 characters!'
  ]
]

const validationRules = {
  id: [[ notEmpty, notEmptyMsg('id') ]],
  users: userSpec,
}

const input = {
  id: 4,
  users: ['foobar', 'foobarbaz']
}

spected(validationRules, input)