valibot

The modular and type safe schema library for validating structural data 🤖

MIT License

Downloads
1.6M
Stars
5.2K
Committers
105

Bot releases are visible (Hide)

valibot - v0.31.0-rc.5 Latest Release

Published by fabian-hiller 5 months ago

Many thanks to @naveen-bharathi for contributing to this release.

To migrate from an older version, please see the official migration guide: https://valibot.dev/guides/migrate-from-v0.30.0/

  • Fix input and output type of intersect schema (issue #601)
valibot - v0.31.0-rc.4

Published by fabian-hiller 5 months ago

Many thanks to @AlexXanderGrib, @chertik77 and @chimame for contributing to this release.

To migrate from an older version, please see the official migration guide: https://valibot.dev/guides/migrate-from-v0.30.0/

  • Change emoji regex to support older JS runtimes (issue #599, #594, #596)
valibot - v0.31.0-rc.3

Published by fabian-hiller 5 months ago

Many thanks to @chimame for contributing to this release.

To migrate from an older version, please see the official migration guide: https://valibot.dev/guides/migrate-from-v0.30.0/

  • Fix context reference of options variable in variant schema (pull request #600)
valibot - v0.31.0-rc.2

Published by fabian-hiller 5 months ago

Many thanks to @jansedlon for contributing to this release.

To migrate from an older version, please see the official migration guide: https://valibot.dev/guides/migrate-from-v0.30.0/

  • Fix Default type for optional, nullable and nullish schema (issue #593)
valibot - v0.31.0-rc.1

Published by fabian-hiller 5 months ago

Many thanks to @jansedlon and @mutewinter for contributing to this release.

To migrate from an older version, please see the official migration guide: https://valibot.dev/guides/migrate-from-v0.30.0/

  • Fix output type of optional, nullable and nullish schema (issue #593, #363)
valibot - v0.31.0-rc.0

Published by fabian-hiller 5 months ago

Many thanks to @Demivan, @EltonLobo07, @xcfox, @mxdvl, @Afsoon, @IlyaSemenov, @Saeris, @devcaeg, @AndreyYolkin, @MrGeniusProgrammer, @znycheporuk, @macarie and many others for contributing to this release.

To migrate from an older version, please see the official migration guide: https://valibot.dev/guides/migrate-from-v0.30.0/

valibot - v0.30.0

Published by fabian-hiller 8 months ago

Many thanks to @Saeris, @ariskemper, @mxdvl, @romeerez and @niccholaspage for contributing to this release.

  • Add Default and DefaultAsync type and refactor codebase
  • Add Fallback and FallbackAsync type and refactor codebase
  • Add isOfType type guard util to check the type of an object
  • Refactor getDefaults and getDefaultsAsync method (pull request #259)
  • Refactor getFallbacks and getFallbacksAsync method (pull request #259)
  • Change type definitions from type to interface (pull request #259, #451)
  • Remove deprecated properties of safeParse and safeParseAsync method
  • Remove any deprecated method, schema and validation functions
  • Fix NestedPath type of flatten for async schemas (issue #456)
  • Fix implementation of DefaultValue type for transformed values
valibot - v0.29.0

Published by fabian-hiller 8 months ago

Many thanks to @Mini-ghost, @ivands and @Demivan for contributing to this release.

  • Add every and some pipeline validation action
  • Add input of schema to getter function of recursive and recursiveAsync schema (pull request #441)
  • Change implementation of transform and transformAsync method to only run transformations if there are no issues (issue #436)
  • Rename recursive and recursiveAsync schema to lazy and lazyAsync (issue #440)
  • Fix bug in i18n util when using setSchemaMessage
valibot - v0.28.1

Published by fabian-hiller 9 months ago

Many thanks to @compulim for contributing to this release.

  • Fix bug in union and unionAsync schema for transformed inputs (issue #420)
valibot - v0.28.0

Published by fabian-hiller 9 months ago

Many thanks to @LorisSigrist, @samuelstroschein, @gmaxlev, @thundermiracle, @ivanhofer, @CanRau, @zkulbeda, @lucaschultz, @paoloricciuti, @hyunbinseo, and @bertez for contributing to this release.

Note: The library has been revised and refactored. Therefore, not every change is listed in detail.

  • Add i18n feature, global configurations and improve error messages (pull request #397)
  • Add number and bigint to PicklistOptions type (issue #378)
  • Fix missing export of forwardAsync method (issue #412)
valibot - v0.27.1

Published by fabian-hiller 9 months ago

Many thanks to @Omochice for contributing to this release.

  • Fix missing file extension for Deno (pull request #387)
valibot - v0.27.0

Published by fabian-hiller 9 months ago

Many thanks to @pschiffmann for contributing to this release.

  • Remove NonNullable, NonNullish and NonOptional type
  • Add NonNullableInput, NonNullableOutput, NonNullishInput, NonNullishOutput, NonOptionalInput and NonOptionalOutput type
  • Improve type signature of omit, omitAsync, pick and pickAsync schema to also allow read-only object keys (issue #380)
  • Fix type of pipe argument at intersect and intersectAsync schema
valibot - v0.26.0

Published by fabian-hiller 9 months ago

Many thanks to @WtfJoke, @dboune, @alexabw and @aypotu for contributing to this release.

  • Improve performance of enum_ and enumAsync schema by caching values
  • Change ISO timestamp regex to support timestamps with lower and higher millisecond accuracy (pull request #353)
  • Change issue handling of union, unionAsync, variant and variantAsync to improve developer experience
  • Fix bug in getDefaults, getDefaultsAsync, getFallbacks and getFallbacksAsync for falsy but not undefined values (issue #356)
  • Fix type of pipe argument at union, unionAsync, variant and variantAsync
  • Fix bug that broke pipeline execution in union, unionAsync, variant and variantAsync (issue #364)
  • Fix typo in type name of startsWith validation action (pull request #375)

Migration guide

The changes in union, unionAsync, variant and variantAsync are breaking changes and may result in different behavior when returning issues. Please create an issue if you have questions about this.

import * as v from 'valibot';

// Change this
const UnionSchema = v.union(
  [v.string([v.email()]), v.literal('')],
  'Not a valid email'
);

// To that
const UnionSchema = v.union([
  v.string([v.email('Not a valid email')]),
  v.literal(''),
]);
valibot - v0.25.0

Published by fabian-hiller 10 months ago

Many thanks to @ariskemper, @ewautr, @cuberoot @lo1tuma and @richardvanbergen for contributing to this release.

  • Add creditCard, decimal, hash, hexadecimal, hexColor and octal pipeline validation action (pull request #292, #304, #307, #308, #309)
  • Add pipe parameter to intersect, intersectAsync, union, unionAsync, variant and variantAsync schema (discussion #297)
  • Add support for multiple variant options with same discriminator key to variant and variantAsync schema (issue #310)
  • Add path to issues if discriminator key of variant and variantAsync schema is missing (issue #235, #303)
  • Change PicklistOptions type and generics of picklist and picklistAsync schema
valibot - v0.24.1

Published by fabian-hiller 10 months ago

Many thanks to @NotWorkingCode for contributing to this release.

  • Fix output type of optional object and objectAsync entries with default value (issue #286)
  • Fix output type of nullable, nullableAsync, nullish, nullishAsync, optional and optionalAsync schema with default value (issue #286)
valibot - v0.24.0

Published by fabian-hiller 10 months ago

Many thanks to @genki and @NotWorkingCode for contributing to this release.

  • Add support for special schema as key of record schema (issue #291)
  • Add support for special and specialAsync schema as key of recordAsync schema (issue #291)
  • Fix input and output type of optional object keys with default value (issue #286)
valibot - v0.23.0

Published by fabian-hiller 11 months ago

Many thanks to @ariskemper, @ivands and @emilgpa for contributing to this release.

  • Add bic validation function (pull request #284)
  • Add mac, mac48 and mac64 validation function (pull request #270)
  • Change PicklistOptions, UnionOptions and UnionOptionsAsync type from tuple to array (issue #279)
  • Change IntersectOptions, IntersectOptionsAsync, UnionOptions and UnionOptionsAsync type to support readonly values (issue #279)
  • Fix optional keys of ObjectInput and ObjectOutput type (issue #242)
valibot - v0.22.0

Published by fabian-hiller 11 months ago

Many thanks to @ecyrbe, @Demivan, @GriefMoDz, @demarchenac, @TFX0019, @AbePlays, @irg1008, @skotenko, @dukeofsoftware, @xxxhussein, @JortsEnjoyer0, @Karakatiza666, @micahjon, @lulucas, @xsjcTony, @ziyak97, @micha149, @anhzf and @jonlambert for contributing to this release.

  • Add support for boolean to notValue validation (pull request #261)
  • Add .typed to schema validation result and execute pipeline of complex schemas if output is typed (issue #76, #145)
  • Add forward method that forwards issues of pipelines to nested fields (issue #76, #145)
  • Add skipPipe option to is type guard method (pull request #166)
  • Change return type of safeParse and safeParseAsync method
  • Rename and change util functions and refactor codebase
  • Fix RecordInput and RecordOuput type when using unionAsync as key
  • Fix output type for nullable, nullableAsync, nullish, nullishAsync, optional and optionalAsync when using a default value (issue #271)
valibot - v0.21.0

Published by fabian-hiller 11 months ago

Many thanks to @Saeris, @lo1tuma, @david-plugge, @ciscoheat, @kazizi55 and @BastiDood for contributing to this release.

  • Change structure of schemas, validations and transformations to make properties accessible (pull request #211)
  • Fix errors in JSDoc comments and add JSDoc ESLint plugin (pull request #205)
  • Fix missing file extension for Deno (pull request #249)

Migration guide

The internal structure of schema and pipeline functions has changed as a result of #211. These changes affect people who have created their own schema, validation, or transformation functions.

import { type BaseValidation, type ErrorMessage, getOutput, getPipeIssues } from 'valibot';

// Change this

export function minLength<TInput extends string | any[]>(
  requirement: number,
  error?: ErrorMessage
) {
  return (input: TInput): PipeResult<TInput> =>
    input.length < requirement
      ? getPipeIssues('min_length', error || 'Invalid length', input)
      : getOutput(input);
}

// To that

export type MinLengthValidation<
  TInput extends string | any[],
  TRequirement extends number
> = BaseValidation<TInput> & {
  type: 'min_length';
  requirement: TRequirement;
};

export function minLength<
  TInput extends string | any[],
  TRequirement extends number
>(
  requirement: TRequirement,
  message: ErrorMessage = 'Invalid length'
): MinLengthValidation<TInput, TRequirement> {
  return {
    type: 'min_length',
    async: false,
    message,
    requirement,
    _parse(input) {
      return input.length < this.requirement
        ? getPipeIssues(this.type, this.message, input, this.requirement)
        : getOutput(input);
    },
  };
}

If you have any questions or problems, please have a look at the source code or create an issue. I usually respond within 24 hours.

valibot - v0.20.1

Published by fabian-hiller 12 months ago

Many thanks to @lo1tuma for contributing to this release.

  • Remove never from type signatur of strict objects and tuples (issue #234)