Skip to content

v0.16.0

Compare
Choose a tag to compare
@fabian-hiller fabian-hiller released this 16 Sep 05:21

Many thanks to @jmcdo29, @divndev and @demarchenac for contributing to this release.

  • Add ulid validation (pull request #151)
  • Add getIssues, getOutput and getPipeIssues util and refactor code
  • Fix type check in number and numberAsync schema (issue #157)
  • Change PipeResult type to allow multiple issues (issue #161)
  • Rename previous getIssues util to getSchemaIssues

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 } from 'valibot';

// 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),
]);