github fabian-hiller/valibot v0.16.0

latest releases: v0.38.0, v0.37.0, v0.36.0...
14 months ago

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 }

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

Don't miss a new valibot release

NewReleases is sending notifications on new releases.