Many thanks to @jmcdo29, @divndev and @demarchenac for contributing to this release.
- Add
ulid
validation (pull request #151) - Add
getIssues
,getOutput
andgetPipeIssues
util and refactor code - Fix type check in
number
andnumberAsync
schema (issue #157) - Change
PipeResult
type to allow multiple issues (issue #161) - Rename previous
getIssues
util togetSchemaIssues
Migration guide
For individual validation within a pipeline, it is now possible to return multiple issues. In addition, we provide two helper functions with getOutput
and getPipeIssues
to make your code more readable.
import { getOutput, getPipeIssues, string }
// Change this
const StringSchema = string([
(input) => {
if (input.length > 10) {
return {
issue: {
validation: 'custom',
message: 'Invalid length',
input,
},
};
}
return { output: input };
},
]);
// To that
const StringSchema = string([
(input) =>
input.length > 10
? getPipeIssues('custom', 'Invalid length', input)
: getOutput(input),
]);