Skip to content

Releases: busypeoples/spected

v0.7.2

03 Feb 18:27
Compare
Choose a tag to compare

What's Changed

New Contributors

Full Changelog: v0.7.1...v0.7.2

v0.7.0

28 Dec 11:30
Compare
Choose a tag to compare
  • Accept Functions as Input (#97) by @AutoSponge
    Spected now also accepts a function as input to validate against.

const verify = validate(a => a, a => a)
const validationRules = {
    name: nameValidationRule,
}
const input = {name: 'foobarbaz'}
const result = verify(validationRules, key => key ? ({...input, [key]: ''}) : input)
deepEqual({name: ['Name should not be empty.']}, result)

v0.6.0

03 Sep 21:30
Compare
Choose a tag to compare

Added passing the field/key when errorMessage is a function (#89 by @Emilios1995)

v0.5.0

16 Jul 16:07
Compare
Choose a tag to compare

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)

v0.4.0

28 Jun 10:31
Compare
Choose a tag to compare

Added dynamic input validations.
Spected runs a defined spec against every property or item for the provided input array or object.

  • Handles a collection of items to validate against.

  • Handles an object with an arbitrary number of properties.