Skip to content

Releases: fabian-hiller/valibot

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.

v0.19.0

09 Oct 00:01
Compare
Choose a tag to compare

Many thanks to @lo1tuma, @Saeris, @sillvva, @kazizi55, @FleetAdmiralJakob, @kurtextrem, @xinha-sh and @husseyexplores for contributing to this release.

  • Add notBytes, notLength, notSize and notValue validation function (pull request #194)
  • Add support for unions as key of record and recordAsync schema (issue #201)
  • Add support for pipeline validation to transform and transformAsync (issue #197)
  • Change regex of email validation to improve performance and security (pull request #180)
  • Change object and objectAsync schema to exclude non-existing keys (issue #199)
  • Fix types at brand, transform and unwrap method (issue #195)
  • Deprecate equal validation function in favor of value (issue #192)

v0.18.0

01 Oct 04:25
Compare
Choose a tag to compare

Many thanks to @alonidiom, @davidmyersdev, @Karakatiza666, @abd2561024 and @brandonpittman for contributing to this release.

  • Add intersection and intersectionAsync schema (pull request #117)
  • Fix RecordInput and RecordOutput type (pull request #184)
  • Change RecordSchema and RecordSchemaAsync type
  • Change flatten function and improve types

v0.17.1

25 Sep 04:30
Compare
Choose a tag to compare

Many thanks to @syhol and @adoublef for contributing to this release.

  • Fix missing file extensions for Deno (pull request #178, #181)

v0.17.0

17 Sep 06:49
Compare
Choose a tag to compare

Many thanks to @zkulbeda, @vicimpa, @jonlambert and @gmaxlev for contributing to this release.

  • Add support for multiple branding of a value (pull request #88)
  • Add support for dynamic error messages via functions (pull request #136)
  • Add skipPipe option to skip execution of pipelines (pull request #164)

v0.16.0

16 Sep 05:21
Compare
Choose a tag to compare

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