Skip to content

Releases: fabian-hiller/valibot

v0.27.0

24 Jan 16:22
Compare
Choose a tag to compare

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

v0.26.0

17 Jan 02:42
Compare
Choose a tag to compare

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 schema to improve developer experience
  • Fix bug in getDefaults, getDefaultsAsync, getFallbacks and getFallbacksAsync schema for falsy but not undefined values (issue #356)
  • Fix type of pipe argument at union, unionAsync, variant and variantAsync schema
  • Fix bug that broke pipeline execution in union, unionAsync, variant and variantAsync schema (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(''),
]);

v0.25.0

27 Dec 03:37
Compare
Choose a tag to compare

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

v0.24.1

11 Dec 16:37
Compare
Choose a tag to compare

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)

v0.24.0

11 Dec 04:14
Compare
Choose a tag to compare

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)

v0.23.0

08 Dec 17:32
Compare
Choose a tag to compare

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)

v0.22.0

03 Dec 18:13
Compare
Choose a tag to compare

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)

v0.21.0

19 Nov 14:59
Compare
Choose a tag to compare

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.

v0.20.1

03 Nov 03:20
Compare
Choose a tag to compare

Many thanks to @lo1tuma for contributing to this release.

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

v0.20.0

31 Oct 05:33
Compare
Choose a tag to compare

Many thanks to @lo1tuma, @Karakatiza666, @naveen-bharathi, @jsudelko, @danielo515, @iamriajul, @brandonpittman, @marek-hanzal, @kurtextrem, @BThomann, @hermanseder, @sillvva, @tjenkinson and many more peoples for contributing to this release.

  • Add getRestAndDefaultArgs utility function
  • Add rest argument to object and objectAsync schema
  • Add variant and variantAsync schema (issue #90, #216)
  • Add getFallback property to schema in fallback method (pull request #177)
  • Add PartialObjectEntries and PartialObjectEntriesAsync type (issue #217)
  • Add export for any validation regex (pull request #219)
  • Add getDefaultAsync, getDefaults and getDefaultsAsync, getFallback, getFallbackAsync, getFallbacks, getFallbacksAsync method (issue #155)
  • Add support for schema validation to transform and transformAsync
  • Fix type check in date and dateAsync for invalid dates (pull request #214)
  • Improve security of regular expressions (pull request #202)
  • Improve optional, optionalAsync, nullable, nullableAsync, nullish and nullishAsync schema
  • Change ObjectSchema and ObjectSchemaAsync type
  • Change type check in tuple and tupleAsync to be less strict
  • Change return type of action argument in coerce and coerceAsync to unknown
  • Change type of brand, getDefault, transform and transformAsync method
  • Change type of array, arrayAsync, intersection, intersectionAsync, map, mapAsync, object, objectAsync, union, unionAsync, record, recordAsync, set, setAsync, tuple and tupleAsync schema
  • Rename schema property of every schema type to type
  • Rename intersection and intersectionAsync schema to intersect and intersectAsync
  • Rename enumType and enumTypeAsync schema to picklist and picklistAsync
  • Rename nativeEnum and nativeEnumAsync schema to enum_ and enumAsync
  • Rename nullType and nullTypeAsync schema to null_ and nullAsync
  • Rename undefinedType and undefinedTypeAsync schema to undefined_ and undefinedAsync
  • Rename voidType and voidTypeAsync schema to void_ and voidAsync
  • Rename default property of optional, optionalAsync, nullable, nullableAsync, nullish and nullishAsync schema to getDefault
  • Rename ObjectShape and ObjectShapeAsync types to ObjectEntries and ObjectEntriesAsync
  • Rename TupleShape and TupleShapeAsync types to TupleItems and TupleItemsAsync
  • Deprecate passthrough, strict and strip method in favor of object schema with rest argument

Migration guide

Unfortunately, I haven't had time to write a migration guide yet. 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.