- 5bc250f [changed] don't clone unspecified object keys
- 069c6fd [added] withMutation() method
- e1d4891 [fixed] don't alias non existent fields
- 686f6b1 [changed] concat() allows mixing "mixed" and other type
breaking
testfunctions are no longer passedpathandcontextas arguments, Instead they are now values onthisinside the test function.- test functions are longer called with the schema as their
thisvalue, usethis.schemainstead.
other changes
- test functions are call with with a new context object, including, options, parent and
createErrorfor dynamically altering validation errors.
- document
stripUnknown - add
recursiveoption - add
noUnknown()test to objects
- default for objects now adds keys for all fields, not just fields with non empty defaults
- bug fix
breaking
testfunctions are now passedpathandcontextvalues along with the field value. Only breaks if using the callback style of defining custom validations
breaking
- the
validation()method has been renamed totest()and has a new signature requiring anameargument - exclusive validations now trump the previous one instead of defering to it e.g:
string().max(10).max(15)has a max of15instead of10
other changes
- expose advanced signature for custom validation tests, gives finer grained control over how tests are added
- added the
abortEarly(default:true) option - transforms are passed an addition parameter: 'originalValue' you allow recovering from a bad transform further up the chain (provided no one mutated the value)
- fix
concat()method and add tests
- fix validations where nullable fields were failing due to
nullvalues e.gstring.max()
- fix export error
breaking
- Removed the
extendandcreatemethods. Use whatever javascript inheritance patterns you want instead. - the resolution order of defaults and coercions has changed. as well as the general handling of
nullvalues.- Number:
nullwill coerce tofalsewhennullable()is not specified.NaNvalues will now failisType()checks - String:
nullwill coerce to''whennullable()is not specified - Date: Invalid dates will not be coerced to
null, but left as invalid date, This is probably not a problem for anyone as invalid dates will also failisType()checks
- Number:
- default values are cloned everytime they are returned, so it is impossible to share references to defaults across schemas. No one should be doing that anyway
- stopped pretending that using schemas as conditions in
when()actually worked (it didn't)
other changes
transform()now passes the original value to each transformer. Allowing you to recover from a bad transform.- added the
equals()alias foroneOf
breaking
- isValid is now async, provide a node style callback, or use the promise the method returns to read the validity. This change allows for more robust validations, specifically remote ones for client code (or db queries for server code). The cast method is still, and will remain, synchronous.
other changes
- added validate method (also async) which resolves to the value, and rejects with a new ValidationError