diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md index 778d50373..0ad371fde 100644 --- a/.github/copilot-instructions.md +++ b/.github/copilot-instructions.md @@ -50,15 +50,15 @@ Each has its own folder: `name.ts`, `name.test.ts`, `name.test-d.ts`, `index.ts` ## Detailed Guides -See `/prompts/index.md` for task-specific instructions: - -| Task | Guide | -| ----------------------------- | --------------------------------------- | -| Navigate repo, find files | `prompts/repository-structure.md` | -| Write JSDoc / inline comments | `prompts/document-source-code.md` | -| Review PRs and source changes | `prompts/review-source-code-changes.md` | -| Add new API page to website | `prompts/add-new-api-to-website.md` | -| Update existing API docs | `prompts/update-api-on-website.md` | -| Add guide/tutorial to website | `prompts/add-new-guide-to-website.md` | +**Before performing any task listed below, OPEN and READ the corresponding guide file.** + +| Task | Guide (read before starting) | +| ----------------------------- | --------------------------------------------------------------------------------- | +| Navigate repo, find files | [prompts/repository-structure.md](../prompts/repository-structure.md) | +| Write JSDoc / inline comments | [prompts/document-source-code.md](../prompts/document-source-code.md) | +| Review PRs and source changes | [prompts/review-source-code-changes.md](../prompts/review-source-code-changes.md) | +| Add new API page to website | [prompts/add-new-api-to-website.md](../prompts/add-new-api-to-website.md) | +| Update existing API docs | [prompts/update-api-on-website.md](../prompts/update-api-on-website.md) | +| Add guide/tutorial to website | [prompts/add-new-guide-to-website.md](../prompts/add-new-guide-to-website.md) | **Source code is the single source of truth.** All documentation must match `/library/src/`. diff --git a/library/CHANGELOG.md b/library/CHANGELOG.md index d6ee87046..3d74101bc 100644 --- a/library/CHANGELOG.md +++ b/library/CHANGELOG.md @@ -2,6 +2,10 @@ All notable changes to the library will be documented in this file. +## vX.X.X (Month DD, YYYY) + +- Add `guard` transformation action to narrow types using type predicates (pull request #1204) + ## v1.2.0 (November 24, 2025) - Add `toBigint`, `toBoolean`, `toDate`, `toNumber` and `toString` transformation actions (pull request #1212) diff --git a/library/src/actions/guard/guard.test-d.ts b/library/src/actions/guard/guard.test-d.ts new file mode 100644 index 000000000..14a061d4b --- /dev/null +++ b/library/src/actions/guard/guard.test-d.ts @@ -0,0 +1,94 @@ +import { describe, expectTypeOf, test } from 'vitest'; +import { pipe } from '../../methods/index.ts'; +import { literal, number, string } from '../../schemas/index.ts'; +import type { InferInput, InferIssue, InferOutput } from '../../types/index.ts'; +import type { GuardAction, GuardIssue } from './guard.ts'; +import { guard } from './guard.ts'; + +describe('guard', () => { + type PixelString = `${number}px`; + const isPixelString = (input: string): input is PixelString => + /^\d+px$/u.test(input); + + describe('should return action object', () => { + test('with no message', () => { + expectTypeOf(guard(isPixelString)).toEqualTypeOf< + GuardAction + >(); + }); + + test('with string message', () => { + expectTypeOf(guard(isPixelString, 'message')).toEqualTypeOf< + GuardAction + >(); + }); + + test('with function message', () => { + expectTypeOf(guard(isPixelString, () => 'message')).toEqualTypeOf< + GuardAction string> + >(); + }); + }); + + describe('should infer correct types', () => { + test('of input', () => { + expectTypeOf< + InferInput> + >().toEqualTypeOf(); + }); + + test('of output', () => { + expectTypeOf< + InferOutput> + >().toEqualTypeOf(); + }); + + test('of issue', () => { + expectTypeOf< + InferIssue> + >().toEqualTypeOf>(); + }); + }); + + test('should infer correct type in pipe', () => { + // eslint-disable-next-line @typescript-eslint/no-unused-vars + const schema = pipe( + string(), + guard((input) => { + expectTypeOf(input).toEqualTypeOf(); + return isPixelString(input); + }) + ); + expectTypeOf>().toEqualTypeOf(); + }); + + test("should error if pipe input doesn't match", () => { + pipe( + number(), + // @ts-expect-error + guard(isPixelString) + ); + }); + + test('should allow narrower input or wider output', () => { + // eslint-disable-next-line @typescript-eslint/no-unused-vars + const narrowInput = pipe( + string(), + // guard allows wider input than current pipe + guard( + (input: unknown) => typeof input === 'string' && isPixelString(input) + ) + ); + + expectTypeOf< + InferOutput + >().toEqualTypeOf(); + + // guarded type is wider than current pipe + // so we keep the narrower type + // eslint-disable-next-line @typescript-eslint/no-unused-vars + const wideOutput = pipe(literal('123px'), guard(isPixelString)); + + expectTypeOf>().toEqualTypeOf<'123px'>(); + }); +}); diff --git a/library/src/actions/guard/guard.test.ts b/library/src/actions/guard/guard.test.ts new file mode 100644 index 000000000..ec45f79d4 --- /dev/null +++ b/library/src/actions/guard/guard.test.ts @@ -0,0 +1,90 @@ +import { describe, expect, test } from 'vitest'; +import type { FailureDataset } from '../../types/dataset.ts'; +import type { GuardAction, GuardIssue } from './guard.ts'; +import { guard } from './guard.ts'; + +describe('guard', () => { + type PixelString = `${number}px`; + const isPixelString = (input: string): input is PixelString => + /^\d+px$/u.test(input); + + const baseAction: Omit< + GuardAction, + 'message' + > = { + kind: 'transformation', + type: 'guard', + reference: guard, + requirement: isPixelString, + async: false, + '~run': expect.any(Function), + }; + + describe('should return action object', () => { + test('with undefined message', () => { + const action: GuardAction = { + ...baseAction, + message: undefined, + }; + expect(guard(isPixelString)).toStrictEqual(action); + expect(guard(isPixelString, undefined)).toStrictEqual(action); + }); + + test('with string message', () => { + const action: GuardAction = { + ...baseAction, + message: 'message', + }; + expect(guard(isPixelString, 'message')).toStrictEqual(action); + }); + + test('with function message', () => { + const message = () => 'message'; + const action: GuardAction = + { + ...baseAction, + message, + }; + expect(guard(isPixelString, message)).toStrictEqual(action); + }); + }); + + test('should return dataset without issues', () => { + const action = guard(isPixelString); + const outputDataset = { typed: true, value: '123px' }; + expect(action['~run']({ typed: true, value: '123px' }, {})).toStrictEqual( + outputDataset + ); + }); + + test('should return dataset with issues', () => { + const action = guard(isPixelString, 'message'); + const baseIssue: Omit< + GuardIssue, + 'input' | 'received' + > = { + kind: 'transformation', + type: 'guard', + expected: null, + message: 'message', + requirement: isPixelString, + path: undefined, + issues: undefined, + lang: undefined, + abortEarly: undefined, + abortPipeEarly: undefined, + }; + + expect(action['~run']({ typed: true, value: '123' }, {})).toStrictEqual({ + typed: false, + value: '123', + issues: [ + { + ...baseIssue, + input: '123', + received: '"123"', + }, + ], + } satisfies FailureDataset>); + }); +}); diff --git a/library/src/actions/guard/guard.ts b/library/src/actions/guard/guard.ts new file mode 100644 index 000000000..550065e1a --- /dev/null +++ b/library/src/actions/guard/guard.ts @@ -0,0 +1,178 @@ +import type { + BaseIssue, + BaseTransformation, + ErrorMessage, +} from '../../types/index.ts'; +import { _addIssue } from '../../utils/index.ts'; + +/** + * Guard function type. + * + * @beta + */ +export type GuardFunction = ( + input: TInput + // eslint-disable-next-line @typescript-eslint/no-explicit-any +) => input is any; + +/** + * Infer guard output type. + * + * @beta + */ +// eslint-disable-next-line @typescript-eslint/no-explicit-any +export type InferGuardOutput> = + // eslint-disable-next-line @typescript-eslint/no-explicit-any + TGuard extends (input: any) => input is infer TOutput ? TOutput : unknown; + +/** + * Guard issue interface. + * + * @beta + */ +export interface GuardIssue> + extends BaseIssue { + /** + * The issue kind. + */ + readonly kind: 'transformation'; + /** + * The issue type. + */ + readonly type: 'guard'; + /** + * The guard function. + */ + readonly requirement: TGuard; +} + +/** + * Guard action interface. + * + * @beta + */ +export interface GuardAction< + TInput, + TGuard extends GuardFunction, + TMessage extends ErrorMessage> | undefined, +> extends BaseTransformation< + TInput, + // intersect in case guard is actually wider + TInput & InferGuardOutput, + GuardIssue + > { + /** + * The action type. + */ + readonly type: 'guard'; + /** + * The action reference. + */ + readonly reference: typeof guard; + /** + * The guard function. + */ + readonly requirement: TGuard; + /** + * The error message. + */ + readonly message: TMessage; +} + +/** + * Creates a guard transformation action. + * + * @param requirement The guard function. + * + * @returns A guard action. + * + * @beta + */ +// known input from pipe +export function guard>( + requirement: TGuard +): GuardAction; + +/** + * Creates a guard transformation action. + * + * @param requirement The guard function. + * + * @returns A guard action. + * + * @beta + */ +// unknown input, e.g. standalone +// eslint-disable-next-line @typescript-eslint/no-explicit-any +export function guard>( + requirement: TGuard +): GuardAction[0], TGuard, undefined>; + +/** + * Creates a guard transformation action. + * + * @param requirement The guard function. + * @param message The error message. + * + * @returns A guard action. + * + * @beta + */ +// known input from pipe +export function guard< + TInput, + const TGuard extends GuardFunction, + const TMessage extends ErrorMessage> | undefined, +>( + requirement: TGuard, + message: TMessage +): GuardAction; + +/** + * Creates a guard transformation action. + * + * @param requirement The guard function. + * @param message The error message. + * + * @returns A guard action. + * + * @beta + */ +// unknown input, e.g. standalone +export function guard< + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const TGuard extends GuardFunction, + const TMessage extends + | ErrorMessage[0], TGuard>> + | undefined, +>( + requirement: TGuard, + message: TMessage +): GuardAction[0], TGuard, TMessage>; + +// @__NO_SIDE_EFFECTS__ +export function guard( + requirement: GuardFunction, + message?: ErrorMessage>> +): GuardAction< + unknown, + GuardFunction, + ErrorMessage>> | undefined +> { + return { + kind: 'transformation', + type: 'guard', + reference: guard, + async: false, + requirement, + message, + '~run'(dataset, config) { + if (dataset.typed && !this.requirement(dataset.value)) { + _addIssue(this, 'input', dataset, config); + // @ts-expect-error + dataset.typed = false; + } + return dataset; + }, + }; +} diff --git a/library/src/actions/guard/index.ts b/library/src/actions/guard/index.ts new file mode 100644 index 000000000..4706a65e3 --- /dev/null +++ b/library/src/actions/guard/index.ts @@ -0,0 +1 @@ +export * from './guard.ts'; diff --git a/library/src/actions/index.ts b/library/src/actions/index.ts index 2b6dd01ef..7a90a29dd 100644 --- a/library/src/actions/index.ts +++ b/library/src/actions/index.ts @@ -25,6 +25,7 @@ export * from './finite/index.ts'; export * from './flavor/index.ts'; export * from './graphemes/index.ts'; export * from './gtValue/index.ts'; +export * from './guard/index.ts'; export * from './hash/index.ts'; export * from './hexadecimal/index.ts'; export * from './hexColor/index.ts'; diff --git a/prompts/add-new-api-to-website.md b/prompts/add-new-api-to-website.md index c58ac6da8..56f3986e5 100644 --- a/prompts/add-new-api-to-website.md +++ b/prompts/add-new-api-to-website.md @@ -271,6 +271,8 @@ Examples: 2. Check `menu.md` to identify potentially related APIs 3. For each related API, edit its `index.mdx` and add the new API to the appropriate `` +**Shortcut:** If your new API is very similar to an existing one (e.g., `guard` is similar to `check`), add it everywhere the similar API appears. This ensures consistent coverage across all related docs. + ### Concept Guides Add the new API to the appropriate guide in `/website/src/routes/guides/`: diff --git a/prompts/document-source-code.md b/prompts/document-source-code.md index 83d6ca5d1..5af22c8c2 100644 --- a/prompts/document-source-code.md +++ b/prompts/document-source-code.md @@ -243,6 +243,16 @@ More complex logic, require more inline comments. 1. Single function with JSDoc including `@internal` 2. `// @__NO_SIDE_EFFECTS__` only if pure +## Terminology Consistency + +JSDoc descriptions must match the `kind` property if present: + +| `kind` Property | JSDoc Wording | +| ------------------ | -------------------------------------- | +| `'schema'` | "Creates a ... schema." | +| `'validation'` | "Creates a ... validation action." | +| `'transformation'` | "Creates a ... transformation action." | + ## Quick Reference ### JSDoc First Lines diff --git a/website/src/components/Property.tsx b/website/src/components/Property.tsx index bc403f208..b44706191 100644 --- a/website/src/components/Property.tsx +++ b/website/src/components/Property.tsx @@ -86,6 +86,11 @@ type DefinitionData = }[]; false: DefinitionData; } + | { + type: 'predicate'; + param: string; + is: DefinitionData; + } | { type: 'custom'; modifier?: string; @@ -345,6 +350,14 @@ const Definition = component$(({ parent, data }) => ( ))} + ) : data.type === 'predicate' ? ( + <> + + {data.param} + + is + + ) : ( <> {data.modifier && ( diff --git a/website/src/routes/api/(actions)/guard/index.mdx b/website/src/routes/api/(actions)/guard/index.mdx new file mode 100644 index 000000000..01fd31d85 --- /dev/null +++ b/website/src/routes/api/(actions)/guard/index.mdx @@ -0,0 +1,136 @@ +--- +title: guard +description: Creates a guard transformation action. +source: /actions/guard/guard.ts +contributors: + - EskiMojo14 +--- + +import { ApiList, Property } from '~/components'; +import { properties } from './properties'; + +# guard + +Creates a guard transformation action. + +```ts +const Action = v.guard(requirement, message); +``` + +## Generics + +- `TInput` +- `TGuard` +- `TMessage` + +## Parameters + +- `requirement` +- `message` + +### Explanation + +With `guard` you can freely validate the input and return `true` if it is valid or `false` otherwise. If the input does not match your `requirement`, you can use `message` to customize the error message. + +This is especially useful if you have an existing type predicate (for example, from an external library). + +> `guard` is useful for narrowing known types. For validating completely unknown values, consider [`custom`](../custom/) instead. + +## Returns + +- `Action` + +## Examples + +The following examples show how `guard` can be used. + +### Pixel string schema + +Schema to validate a pixel string. + +```ts +const PixelStringSchema = v.pipe( + v.string(), + v.guard((input): input is `${number}px` => /^\d+px$/.test(input)) +); +``` + +### Axios Error schema + +Schema to validate an object containing an Axios error. + +```ts +import { isAxiosError } from 'axios'; + +const AxiosErrorSchema = v.object({ + error: v.pipe( + v.instance(Error), + v.guard(isAxiosError, 'The error is not an Axios error.') + ), +}); +``` + +## Related + +The following APIs can be combined with `guard`. + +### Schemas + + + +### Methods + + + +### Utils + + diff --git a/website/src/routes/api/(actions)/guard/properties.ts b/website/src/routes/api/(actions)/guard/properties.ts new file mode 100644 index 000000000..50405d577 --- /dev/null +++ b/website/src/routes/api/(actions)/guard/properties.ts @@ -0,0 +1,86 @@ +import type { PropertyProps } from '~/components'; + +export const properties: Record = { + TInput: { + modifier: 'extends', + type: 'any', + }, + TGuard: { + modifier: 'extends', + type: { + type: 'custom', + name: 'GuardFunction', + href: '../GuardFunction/', + generics: [ + { + type: 'custom', + name: 'TInput', + }, + ], + }, + }, + TMessage: { + modifier: 'extends', + type: { + type: 'union', + options: [ + { + type: 'custom', + name: 'ErrorMessage', + href: '../ErrorMessage/', + generics: [ + { + type: 'custom', + name: 'GuardIssue', + href: '../GuardIssue/', + generics: [ + { + type: 'custom', + name: 'TInput', + }, + { + type: 'custom', + name: 'TGuard', + }, + ], + }, + ], + }, + 'undefined', + ], + }, + }, + requirement: { + type: { + type: 'custom', + name: 'TGuard', + }, + }, + message: { + type: { + type: 'custom', + name: 'TMessage', + }, + }, + Action: { + type: { + type: 'custom', + name: 'GuardAction', + href: '../GuardAction/', + generics: [ + { + type: 'custom', + name: 'TInput', + }, + { + type: 'custom', + name: 'TGuard', + }, + { + type: 'custom', + name: 'TMessage', + }, + ], + }, + }, +}; diff --git a/website/src/routes/api/(async)/arrayAsync/index.mdx b/website/src/routes/api/(async)/arrayAsync/index.mdx index 5e4fade31..844ad454b 100644 --- a/website/src/routes/api/(async)/arrayAsync/index.mdx +++ b/website/src/routes/api/(async)/arrayAsync/index.mdx @@ -132,6 +132,7 @@ The following APIs can be combined with `arrayAsync`. 'filterItems', 'findItem', 'flavor', + 'guard', 'includes', 'length', 'mapItems', diff --git a/website/src/routes/api/(async)/customAsync/index.mdx b/website/src/routes/api/(async)/customAsync/index.mdx index 651b296c1..472a799bb 100644 --- a/website/src/routes/api/(async)/customAsync/index.mdx +++ b/website/src/routes/api/(async)/customAsync/index.mdx @@ -132,6 +132,7 @@ The following APIs can be combined with `customAsync`. 'flavor', 'graphemes', 'gtValue', + 'guard', 'hash', 'hexadecimal', 'hexColor', diff --git a/website/src/routes/api/(async)/exactOptionalAsync/index.mdx b/website/src/routes/api/(async)/exactOptionalAsync/index.mdx index e5994b3fe..a027b34e6 100644 --- a/website/src/routes/api/(async)/exactOptionalAsync/index.mdx +++ b/website/src/routes/api/(async)/exactOptionalAsync/index.mdx @@ -162,6 +162,7 @@ The following APIs can be combined with `exactOptionalAsync`. 'check', 'description', 'flavor', + 'guard', 'metadata', 'partialCheck', 'rawCheck', diff --git a/website/src/routes/api/(async)/fallbackAsync/index.mdx b/website/src/routes/api/(async)/fallbackAsync/index.mdx index 83b00230a..463dc061d 100644 --- a/website/src/routes/api/(async)/fallbackAsync/index.mdx +++ b/website/src/routes/api/(async)/fallbackAsync/index.mdx @@ -160,6 +160,7 @@ The following APIs can be combined with `fallbackAsync`. 'flavor', 'graphemes', 'gtValue', + 'guard', 'hash', 'hexadecimal', 'hexColor', diff --git a/website/src/routes/api/(async)/forwardAsync/index.mdx b/website/src/routes/api/(async)/forwardAsync/index.mdx index 0dfb34339..6b353791c 100644 --- a/website/src/routes/api/(async)/forwardAsync/index.mdx +++ b/website/src/routes/api/(async)/forwardAsync/index.mdx @@ -108,6 +108,7 @@ The following APIs can be combined with `forwardAsync`. 'excludes', 'filterItems', 'findItem', + 'guard', 'includes', 'length', 'mapItems', diff --git a/website/src/routes/api/(async)/intersectAsync/index.mdx b/website/src/routes/api/(async)/intersectAsync/index.mdx index 71c0418d8..f2f225427 100644 --- a/website/src/routes/api/(async)/intersectAsync/index.mdx +++ b/website/src/routes/api/(async)/intersectAsync/index.mdx @@ -162,6 +162,7 @@ The following APIs can be combined with `intersectAsync`. 'flavor', 'graphemes', 'gtValue', + 'guard', 'hash', 'hexColor', 'hexadecimal', diff --git a/website/src/routes/api/(async)/lazyAsync/index.mdx b/website/src/routes/api/(async)/lazyAsync/index.mdx index a54ac4a70..f2a13999b 100644 --- a/website/src/routes/api/(async)/lazyAsync/index.mdx +++ b/website/src/routes/api/(async)/lazyAsync/index.mdx @@ -194,6 +194,7 @@ The following APIs can be combined with `lazyAsync`. 'flavor', 'graphemes', 'gtValue', + 'guard', 'hash', 'hexColor', 'hexadecimal', diff --git a/website/src/routes/api/(async)/looseObjectAsync/index.mdx b/website/src/routes/api/(async)/looseObjectAsync/index.mdx index bf3676d7d..783d24167 100644 --- a/website/src/routes/api/(async)/looseObjectAsync/index.mdx +++ b/website/src/routes/api/(async)/looseObjectAsync/index.mdx @@ -132,6 +132,7 @@ The following APIs can be combined with `looseObjectAsync`. 'brand', 'check', 'flavor', + 'guard', 'partialCheck', 'rawCheck', 'rawTransform', diff --git a/website/src/routes/api/(async)/looseTupleAsync/index.mdx b/website/src/routes/api/(async)/looseTupleAsync/index.mdx index faab6cacd..ef5749462 100644 --- a/website/src/routes/api/(async)/looseTupleAsync/index.mdx +++ b/website/src/routes/api/(async)/looseTupleAsync/index.mdx @@ -133,6 +133,7 @@ The following APIs can be combined with `looseTupleAsync`. 'filterItems', 'findItem', 'flavor', + 'guard', 'includes', 'length', 'mapItems', diff --git a/website/src/routes/api/(async)/mapAsync/index.mdx b/website/src/routes/api/(async)/mapAsync/index.mdx index 16e3cd191..babae70a0 100644 --- a/website/src/routes/api/(async)/mapAsync/index.mdx +++ b/website/src/routes/api/(async)/mapAsync/index.mdx @@ -126,6 +126,7 @@ The following APIs can be combined with `mapAsync`. 'brand', 'description', 'flavor', + 'guard', 'maxSize', 'metadata', 'minSize', diff --git a/website/src/routes/api/(async)/nonNullableAsync/index.mdx b/website/src/routes/api/(async)/nonNullableAsync/index.mdx index b8d8ead67..9aef74c32 100644 --- a/website/src/routes/api/(async)/nonNullableAsync/index.mdx +++ b/website/src/routes/api/(async)/nonNullableAsync/index.mdx @@ -130,6 +130,7 @@ The following APIs can be combined with `nonNullableAsync`. 'check', 'description', 'flavor', + 'guard', 'metadata', 'partialCheck', 'rawCheck', diff --git a/website/src/routes/api/(async)/nonNullishAsync/index.mdx b/website/src/routes/api/(async)/nonNullishAsync/index.mdx index fcc8c723e..59790b4af 100644 --- a/website/src/routes/api/(async)/nonNullishAsync/index.mdx +++ b/website/src/routes/api/(async)/nonNullishAsync/index.mdx @@ -126,6 +126,7 @@ The following APIs can be combined with `nonNullishAsync`. 'check', 'description', 'flavor', + 'guard', 'metadata', 'partialCheck', 'rawCheck', diff --git a/website/src/routes/api/(async)/nonOptionalAsync/index.mdx b/website/src/routes/api/(async)/nonOptionalAsync/index.mdx index a68d51c97..a8379a434 100644 --- a/website/src/routes/api/(async)/nonOptionalAsync/index.mdx +++ b/website/src/routes/api/(async)/nonOptionalAsync/index.mdx @@ -136,6 +136,7 @@ The following APIs can be combined with `nonOptionalAsync`. 'check', 'description', 'flavor', + 'guard', 'metadata', 'partialCheck', 'rawCheck', diff --git a/website/src/routes/api/(async)/nullableAsync/index.mdx b/website/src/routes/api/(async)/nullableAsync/index.mdx index 1f5334b0a..0ffdbcfde 100644 --- a/website/src/routes/api/(async)/nullableAsync/index.mdx +++ b/website/src/routes/api/(async)/nullableAsync/index.mdx @@ -150,6 +150,7 @@ The following APIs can be combined with `nullableAsync`. 'check', 'description', 'flavor', + 'guard', 'metadata', 'partialCheck', 'rawCheck', diff --git a/website/src/routes/api/(async)/nullishAsync/index.mdx b/website/src/routes/api/(async)/nullishAsync/index.mdx index 560df4b2c..80798e624 100644 --- a/website/src/routes/api/(async)/nullishAsync/index.mdx +++ b/website/src/routes/api/(async)/nullishAsync/index.mdx @@ -183,6 +183,7 @@ The following APIs can be combined with `nullishAsync`. 'check', 'description', 'flavor', + 'guard', 'metadata', 'partialCheck', 'rawCheck', diff --git a/website/src/routes/api/(async)/objectAsync/index.mdx b/website/src/routes/api/(async)/objectAsync/index.mdx index 987c09849..e55fd4e02 100644 --- a/website/src/routes/api/(async)/objectAsync/index.mdx +++ b/website/src/routes/api/(async)/objectAsync/index.mdx @@ -134,6 +134,7 @@ The following APIs can be combined with `objectAsync`. 'description', 'entries', 'flavor', + 'guard', 'maxEntries', 'metadata', 'minEntries', diff --git a/website/src/routes/api/(async)/objectWithRestAsync/index.mdx b/website/src/routes/api/(async)/objectWithRestAsync/index.mdx index f33853914..104ae121e 100644 --- a/website/src/routes/api/(async)/objectWithRestAsync/index.mdx +++ b/website/src/routes/api/(async)/objectWithRestAsync/index.mdx @@ -148,6 +148,7 @@ The following APIs can be combined with `objectWithRestAsync`. 'description', 'entries', 'flavor', + 'guard', 'maxEntries', 'metadata', 'minEntries', diff --git a/website/src/routes/api/(async)/optionalAsync/index.mdx b/website/src/routes/api/(async)/optionalAsync/index.mdx index 4f9fdeef4..5729a4f55 100644 --- a/website/src/routes/api/(async)/optionalAsync/index.mdx +++ b/website/src/routes/api/(async)/optionalAsync/index.mdx @@ -183,6 +183,7 @@ The following APIs can be combined with `optionalAsync`. 'check', 'description', 'flavor', + 'guard', 'metadata', 'partialCheck', 'rawCheck', diff --git a/website/src/routes/api/(async)/partialAsync/index.mdx b/website/src/routes/api/(async)/partialAsync/index.mdx index 48f3f231e..7dd8245f8 100644 --- a/website/src/routes/api/(async)/partialAsync/index.mdx +++ b/website/src/routes/api/(async)/partialAsync/index.mdx @@ -140,6 +140,7 @@ The following APIs can be combined with `partialAsync`. 'description', 'entries', 'flavor', + 'guard', 'maxEntries', 'metadata', 'minEntries', diff --git a/website/src/routes/api/(async)/pipeAsync/index.mdx b/website/src/routes/api/(async)/pipeAsync/index.mdx index 9edc459b5..5398f8131 100644 --- a/website/src/routes/api/(async)/pipeAsync/index.mdx +++ b/website/src/routes/api/(async)/pipeAsync/index.mdx @@ -199,6 +199,7 @@ The following APIs can be combined with `pipeAsync`. 'flavor', 'graphemes', 'gtValue', + 'guard', 'hash', 'hexadecimal', 'hexColor', diff --git a/website/src/routes/api/(async)/recordAsync/index.mdx b/website/src/routes/api/(async)/recordAsync/index.mdx index ecfc15d01..7c1e9eab5 100644 --- a/website/src/routes/api/(async)/recordAsync/index.mdx +++ b/website/src/routes/api/(async)/recordAsync/index.mdx @@ -133,6 +133,7 @@ The following APIs can be combined with `recordAsync`. 'description', 'entries', 'flavor', + 'guard', 'maxEntries', 'metadata', 'minEntries', diff --git a/website/src/routes/api/(async)/requiredAsync/index.mdx b/website/src/routes/api/(async)/requiredAsync/index.mdx index 19a9cbd06..8918c4561 100644 --- a/website/src/routes/api/(async)/requiredAsync/index.mdx +++ b/website/src/routes/api/(async)/requiredAsync/index.mdx @@ -146,6 +146,7 @@ The following APIs can be combined with `requiredAsync`. 'description', 'entries', 'flavor', + 'guard', 'maxEntries', 'metadata', 'minEntries', diff --git a/website/src/routes/api/(async)/setAsync/index.mdx b/website/src/routes/api/(async)/setAsync/index.mdx index a8c00317e..fd3f922f5 100644 --- a/website/src/routes/api/(async)/setAsync/index.mdx +++ b/website/src/routes/api/(async)/setAsync/index.mdx @@ -124,6 +124,7 @@ The following APIs can be combined with `setAsync`. 'check', 'description', 'flavor', + 'guard', 'maxSize', 'metadata', 'minSize', diff --git a/website/src/routes/api/(async)/strictObjectAsync/index.mdx b/website/src/routes/api/(async)/strictObjectAsync/index.mdx index 72f5c041f..dcc963c50 100644 --- a/website/src/routes/api/(async)/strictObjectAsync/index.mdx +++ b/website/src/routes/api/(async)/strictObjectAsync/index.mdx @@ -134,6 +134,7 @@ The following APIs can be combined with `strictObjectAsync`. 'description', 'entries', 'flavor', + 'guard', 'maxEntries', 'metadata', 'minEntries', diff --git a/website/src/routes/api/(async)/strictTupleAsync/index.mdx b/website/src/routes/api/(async)/strictTupleAsync/index.mdx index 6f7327af7..15736ce08 100644 --- a/website/src/routes/api/(async)/strictTupleAsync/index.mdx +++ b/website/src/routes/api/(async)/strictTupleAsync/index.mdx @@ -133,6 +133,7 @@ The following APIs can be combined with `strictTupleAsync`. 'filterItems', 'findItem', 'flavor', + 'guard', 'includes', 'length', 'mapItems', diff --git a/website/src/routes/api/(async)/tupleAsync/index.mdx b/website/src/routes/api/(async)/tupleAsync/index.mdx index 0ec5f23a8..f26b9b73b 100644 --- a/website/src/routes/api/(async)/tupleAsync/index.mdx +++ b/website/src/routes/api/(async)/tupleAsync/index.mdx @@ -133,6 +133,7 @@ The following APIs can be combined with `tupleAsync`. 'filterItems', 'findItem', 'flavor', + 'guard', 'includes', 'length', 'mapItems', diff --git a/website/src/routes/api/(async)/tupleWithRestAsync/index.mdx b/website/src/routes/api/(async)/tupleWithRestAsync/index.mdx index a598a43c1..6eddd93ec 100644 --- a/website/src/routes/api/(async)/tupleWithRestAsync/index.mdx +++ b/website/src/routes/api/(async)/tupleWithRestAsync/index.mdx @@ -140,6 +140,7 @@ The following APIs can be combined with `tupleWithRestAsync`. 'filterItems', 'findItem', 'flavor', + 'guard', 'includes', 'length', 'mapItems', diff --git a/website/src/routes/api/(async)/undefinedableAsync/index.mdx b/website/src/routes/api/(async)/undefinedableAsync/index.mdx index 6ca228f0c..1e2558936 100644 --- a/website/src/routes/api/(async)/undefinedableAsync/index.mdx +++ b/website/src/routes/api/(async)/undefinedableAsync/index.mdx @@ -185,6 +185,7 @@ The following APIs can be combined with `undefinedableAsync`. 'check', 'description', 'flavor', + 'guard', 'metadata', 'partialCheck', 'rawCheck', diff --git a/website/src/routes/api/(async)/unionAsync/index.mdx b/website/src/routes/api/(async)/unionAsync/index.mdx index 503ba9e1d..88d41373e 100644 --- a/website/src/routes/api/(async)/unionAsync/index.mdx +++ b/website/src/routes/api/(async)/unionAsync/index.mdx @@ -155,6 +155,7 @@ The following APIs can be combined with `unionAsync`. 'flavor', 'graphemes', 'gtValue', + 'guard', 'hash', 'hexadecimal', 'hexColor', diff --git a/website/src/routes/api/(async)/variantAsync/index.mdx b/website/src/routes/api/(async)/variantAsync/index.mdx index 056d5d008..871903649 100644 --- a/website/src/routes/api/(async)/variantAsync/index.mdx +++ b/website/src/routes/api/(async)/variantAsync/index.mdx @@ -135,6 +135,7 @@ The following APIs can be combined with `variantAsync`. 'description', 'entries', 'flavor', + 'guard', 'maxEntries', 'metadata', 'minEntries', diff --git a/website/src/routes/api/(methods)/config/index.mdx b/website/src/routes/api/(methods)/config/index.mdx index 322e1c1ad..78f270b44 100644 --- a/website/src/routes/api/(methods)/config/index.mdx +++ b/website/src/routes/api/(methods)/config/index.mdx @@ -179,6 +179,7 @@ The following APIs can be combined with `config`. 'flavor', 'graphemes', 'gtValue', + 'guard', 'hash', 'hexadecimal', 'hexColor', diff --git a/website/src/routes/api/(methods)/fallback/index.mdx b/website/src/routes/api/(methods)/fallback/index.mdx index ecf740866..2b7b18fe9 100644 --- a/website/src/routes/api/(methods)/fallback/index.mdx +++ b/website/src/routes/api/(methods)/fallback/index.mdx @@ -177,6 +177,7 @@ The following APIs can be combined with `fallback`. 'flavor', 'graphemes', 'gtValue', + 'guard', 'hash', 'hexadecimal', 'hexColor', diff --git a/website/src/routes/api/(methods)/forward/index.mdx b/website/src/routes/api/(methods)/forward/index.mdx index 5f49734af..139e577c9 100644 --- a/website/src/routes/api/(methods)/forward/index.mdx +++ b/website/src/routes/api/(methods)/forward/index.mdx @@ -111,6 +111,7 @@ The following APIs can be combined with `forward`. 'excludes', 'filterItems', 'findItem', + 'guard', 'includes', 'length', 'mapItems', diff --git a/website/src/routes/api/(methods)/keyof/index.mdx b/website/src/routes/api/(methods)/keyof/index.mdx index 1d5aeae3f..827eb9e4b 100644 --- a/website/src/routes/api/(methods)/keyof/index.mdx +++ b/website/src/routes/api/(methods)/keyof/index.mdx @@ -108,6 +108,7 @@ The following APIs can be combined with `keyof`. 'brand', 'description', 'flavor', + 'guard', 'metadata', 'rawCheck', 'rawTransform', diff --git a/website/src/routes/api/(methods)/message/index.mdx b/website/src/routes/api/(methods)/message/index.mdx index 6ea384cc4..48064032c 100644 --- a/website/src/routes/api/(methods)/message/index.mdx +++ b/website/src/routes/api/(methods)/message/index.mdx @@ -163,6 +163,7 @@ The following APIs can be combined with `message`. 'flavor', 'graphemes', 'gtValue', + 'guard', 'hash', 'hexadecimal', 'hexColor', diff --git a/website/src/routes/api/(methods)/omit/index.mdx b/website/src/routes/api/(methods)/omit/index.mdx index 966ed97e7..ab36165a5 100644 --- a/website/src/routes/api/(methods)/omit/index.mdx +++ b/website/src/routes/api/(methods)/omit/index.mdx @@ -127,6 +127,7 @@ The following APIs can be combined with `omit`. 'description', 'entries', 'flavor', + 'guard', 'maxEntries', 'metadata', 'minEntries', diff --git a/website/src/routes/api/(methods)/partial/index.mdx b/website/src/routes/api/(methods)/partial/index.mdx index 82c9bb05b..34e1d672f 100644 --- a/website/src/routes/api/(methods)/partial/index.mdx +++ b/website/src/routes/api/(methods)/partial/index.mdx @@ -140,6 +140,7 @@ The following APIs can be combined with `partial`. 'description', 'entries', 'flavor', + 'guard', 'maxEntries', 'metadata', 'minEntries', diff --git a/website/src/routes/api/(methods)/pick/index.mdx b/website/src/routes/api/(methods)/pick/index.mdx index 4739a47d8..c15bca499 100644 --- a/website/src/routes/api/(methods)/pick/index.mdx +++ b/website/src/routes/api/(methods)/pick/index.mdx @@ -127,6 +127,7 @@ The following APIs can be combined with `pick`. 'description', 'entries', 'flavor', + 'guard', 'maxEntries', 'metadata', 'minEntries', diff --git a/website/src/routes/api/(methods)/required/index.mdx b/website/src/routes/api/(methods)/required/index.mdx index 98af343d3..47d34f22d 100644 --- a/website/src/routes/api/(methods)/required/index.mdx +++ b/website/src/routes/api/(methods)/required/index.mdx @@ -149,6 +149,7 @@ The following APIs can be combined with `required`. 'description', 'entries', 'flavor', + 'guard', 'maxEntries', 'metadata', 'minEntries', diff --git a/website/src/routes/api/(schemas)/array/index.mdx b/website/src/routes/api/(schemas)/array/index.mdx index 36bb55651..42cb95ad1 100644 --- a/website/src/routes/api/(schemas)/array/index.mdx +++ b/website/src/routes/api/(schemas)/array/index.mdx @@ -173,6 +173,7 @@ The following APIs can be combined with `array`. 'filterItems', 'findItem', 'flavor', + 'guard', 'includes', 'length', 'mapItems', diff --git a/website/src/routes/api/(schemas)/bigint/index.mdx b/website/src/routes/api/(schemas)/bigint/index.mdx index 38d5c2f00..355a4447b 100644 --- a/website/src/routes/api/(schemas)/bigint/index.mdx +++ b/website/src/routes/api/(schemas)/bigint/index.mdx @@ -118,6 +118,7 @@ The following APIs can be combined with `bigint`. 'description', 'flavor', 'gtValue', + 'guard', 'ltValue', 'maxValue', 'metadata', diff --git a/website/src/routes/api/(schemas)/blob/index.mdx b/website/src/routes/api/(schemas)/blob/index.mdx index 28c51201c..a219c428a 100644 --- a/website/src/routes/api/(schemas)/blob/index.mdx +++ b/website/src/routes/api/(schemas)/blob/index.mdx @@ -114,6 +114,7 @@ The following APIs can be combined with `blob`. 'brand', 'description', 'flavor', + 'guard', 'maxSize', 'metadata', 'mimeType', diff --git a/website/src/routes/api/(schemas)/boolean/index.mdx b/website/src/routes/api/(schemas)/boolean/index.mdx index 0d5afb947..244d6f546 100644 --- a/website/src/routes/api/(schemas)/boolean/index.mdx +++ b/website/src/routes/api/(schemas)/boolean/index.mdx @@ -113,6 +113,7 @@ The following APIs can be combined with `boolean`. 'description', 'flavor', 'gtValue', + 'guard', 'ltValue', 'maxValue', 'maxWords', diff --git a/website/src/routes/api/(schemas)/date/index.mdx b/website/src/routes/api/(schemas)/date/index.mdx index e93fd0e30..a6e30e0f3 100644 --- a/website/src/routes/api/(schemas)/date/index.mdx +++ b/website/src/routes/api/(schemas)/date/index.mdx @@ -123,6 +123,7 @@ The following APIs can be combined with `date`. 'description', 'flavor', 'gtValue', + 'guard', 'ltValue', 'maxValue', 'metadata', diff --git a/website/src/routes/api/(schemas)/enum/index.mdx b/website/src/routes/api/(schemas)/enum/index.mdx index 3fdaf5db4..c5369e519 100644 --- a/website/src/routes/api/(schemas)/enum/index.mdx +++ b/website/src/routes/api/(schemas)/enum/index.mdx @@ -115,6 +115,7 @@ The following APIs can be combined with `enum`. 'brand', 'description', 'flavor', + 'guard', 'metadata', 'rawCheck', 'rawTransform', diff --git a/website/src/routes/api/(schemas)/exactOptional/index.mdx b/website/src/routes/api/(schemas)/exactOptional/index.mdx index 68367af68..9246c59e9 100644 --- a/website/src/routes/api/(schemas)/exactOptional/index.mdx +++ b/website/src/routes/api/(schemas)/exactOptional/index.mdx @@ -150,6 +150,7 @@ The following APIs can be combined with `exactOptional`. 'brand', 'description', 'flavor', + 'guard', 'metadata', 'partialCheck', 'rawCheck', diff --git a/website/src/routes/api/(schemas)/file/index.mdx b/website/src/routes/api/(schemas)/file/index.mdx index 1373debd6..0aa999f3f 100644 --- a/website/src/routes/api/(schemas)/file/index.mdx +++ b/website/src/routes/api/(schemas)/file/index.mdx @@ -114,6 +114,7 @@ The following APIs can be combined with `file`. 'brand', 'description', 'flavor', + 'guard', 'maxSize', 'metadata', 'mimeType', diff --git a/website/src/routes/api/(schemas)/function/index.mdx b/website/src/routes/api/(schemas)/function/index.mdx index 4e30f3605..6e228485a 100644 --- a/website/src/routes/api/(schemas)/function/index.mdx +++ b/website/src/routes/api/(schemas)/function/index.mdx @@ -96,6 +96,7 @@ The following APIs can be combined with `function`. 'brand', 'description', 'flavor', + 'guard', 'metadata', 'rawCheck', 'rawTransform', diff --git a/website/src/routes/api/(schemas)/intersect/index.mdx b/website/src/routes/api/(schemas)/intersect/index.mdx index ac5aaec44..bb333f4cd 100644 --- a/website/src/routes/api/(schemas)/intersect/index.mdx +++ b/website/src/routes/api/(schemas)/intersect/index.mdx @@ -160,6 +160,7 @@ The following APIs can be combined with `intersect`. 'flavor', 'graphemes', 'gtValue', + 'guard', 'hash', 'hexadecimal', 'hexColor', diff --git a/website/src/routes/api/(schemas)/lazy/index.mdx b/website/src/routes/api/(schemas)/lazy/index.mdx index 3d38f2a5d..517fc72c5 100644 --- a/website/src/routes/api/(schemas)/lazy/index.mdx +++ b/website/src/routes/api/(schemas)/lazy/index.mdx @@ -223,6 +223,7 @@ The following APIs can be combined with `lazy`. 'flavor', 'graphemes', 'gtValue', + 'guard', 'hash', 'hexadecimal', 'hexColor', diff --git a/website/src/routes/api/(schemas)/literal/index.mdx b/website/src/routes/api/(schemas)/literal/index.mdx index af6cadab1..0a27a52ff 100644 --- a/website/src/routes/api/(schemas)/literal/index.mdx +++ b/website/src/routes/api/(schemas)/literal/index.mdx @@ -126,6 +126,7 @@ The following APIs can be combined with `literal`. 'brand', 'description', 'flavor', + 'guard', 'metadata', 'rawCheck', 'rawTransform', diff --git a/website/src/routes/api/(schemas)/looseObject/index.mdx b/website/src/routes/api/(schemas)/looseObject/index.mdx index ee71fbefe..6faf1c1d3 100644 --- a/website/src/routes/api/(schemas)/looseObject/index.mdx +++ b/website/src/routes/api/(schemas)/looseObject/index.mdx @@ -185,6 +185,7 @@ The following APIs can be combined with `looseObject`. 'description', 'entries', 'flavor', + 'guard', 'maxEntries', 'metadata', 'minEntries', diff --git a/website/src/routes/api/(schemas)/looseTuple/index.mdx b/website/src/routes/api/(schemas)/looseTuple/index.mdx index 61143555f..c0551ac53 100644 --- a/website/src/routes/api/(schemas)/looseTuple/index.mdx +++ b/website/src/routes/api/(schemas)/looseTuple/index.mdx @@ -140,6 +140,7 @@ The following APIs can be combined with `looseTuple`. 'filterItems', 'findItem', 'flavor', + 'guard', 'includes', 'length', 'mapItems', diff --git a/website/src/routes/api/(schemas)/map/index.mdx b/website/src/routes/api/(schemas)/map/index.mdx index 0ab7a4733..021f0c3b2 100644 --- a/website/src/routes/api/(schemas)/map/index.mdx +++ b/website/src/routes/api/(schemas)/map/index.mdx @@ -142,6 +142,7 @@ The following APIs can be combined with `map`. 'brand', 'description', 'flavor', + 'guard', 'maxSize', 'metadata', 'minSize', diff --git a/website/src/routes/api/(schemas)/nan/index.mdx b/website/src/routes/api/(schemas)/nan/index.mdx index 68b57da8d..da0772e88 100644 --- a/website/src/routes/api/(schemas)/nan/index.mdx +++ b/website/src/routes/api/(schemas)/nan/index.mdx @@ -96,6 +96,7 @@ The following APIs can be combined with `nan`. 'brand', 'description', 'flavor', + 'guard', 'metadata', 'rawCheck', 'rawTransform', diff --git a/website/src/routes/api/(schemas)/nonNullable/index.mdx b/website/src/routes/api/(schemas)/nonNullable/index.mdx index 3d6a9ca34..14f2d7c28 100644 --- a/website/src/routes/api/(schemas)/nonNullable/index.mdx +++ b/website/src/routes/api/(schemas)/nonNullable/index.mdx @@ -144,6 +144,7 @@ The following APIs can be combined with `nonNullable`. 'brand', 'description', 'flavor', + 'guard', 'metadata', 'partialCheck', 'rawCheck', diff --git a/website/src/routes/api/(schemas)/nonNullish/index.mdx b/website/src/routes/api/(schemas)/nonNullish/index.mdx index 1c2bc1eae..b77068226 100644 --- a/website/src/routes/api/(schemas)/nonNullish/index.mdx +++ b/website/src/routes/api/(schemas)/nonNullish/index.mdx @@ -144,6 +144,7 @@ The following APIs can be combined with `nonNullish`. 'brand', 'description', 'flavor', + 'guard', 'metadata', 'partialCheck', 'rawCheck', diff --git a/website/src/routes/api/(schemas)/nonOptional/index.mdx b/website/src/routes/api/(schemas)/nonOptional/index.mdx index 0225b17ae..8073d3baa 100644 --- a/website/src/routes/api/(schemas)/nonOptional/index.mdx +++ b/website/src/routes/api/(schemas)/nonOptional/index.mdx @@ -144,6 +144,7 @@ The following APIs can be combined with `nonOptional`. 'brand', 'description', 'flavor', + 'guard', 'metadata', 'partialCheck', 'rawCheck', diff --git a/website/src/routes/api/(schemas)/null/index.mdx b/website/src/routes/api/(schemas)/null/index.mdx index e2fb60e4b..8d99f9d92 100644 --- a/website/src/routes/api/(schemas)/null/index.mdx +++ b/website/src/routes/api/(schemas)/null/index.mdx @@ -96,6 +96,7 @@ The following APIs can be combined with `null`. 'brand', 'description', 'flavor', + 'guard', 'metadata', 'rawCheck', 'rawTransform', diff --git a/website/src/routes/api/(schemas)/nullable/index.mdx b/website/src/routes/api/(schemas)/nullable/index.mdx index c10d64e5d..84ad73dfc 100644 --- a/website/src/routes/api/(schemas)/nullable/index.mdx +++ b/website/src/routes/api/(schemas)/nullable/index.mdx @@ -165,6 +165,7 @@ The following APIs can be combined with `nullable`. 'brand', 'description', 'flavor', + 'guard', 'metadata', 'partialCheck', 'rawCheck', diff --git a/website/src/routes/api/(schemas)/nullish/index.mdx b/website/src/routes/api/(schemas)/nullish/index.mdx index 92f0bebc2..dff0665ce 100644 --- a/website/src/routes/api/(schemas)/nullish/index.mdx +++ b/website/src/routes/api/(schemas)/nullish/index.mdx @@ -165,6 +165,7 @@ The following APIs can be combined with `nullish`. 'brand', 'description', 'flavor', + 'guard', 'metadata', 'partialCheck', 'rawCheck', diff --git a/website/src/routes/api/(schemas)/number/index.mdx b/website/src/routes/api/(schemas)/number/index.mdx index b2607d673..3973630b4 100644 --- a/website/src/routes/api/(schemas)/number/index.mdx +++ b/website/src/routes/api/(schemas)/number/index.mdx @@ -127,6 +127,7 @@ The following APIs can be combined with `number`. 'finite', 'flavor', 'gtValue', + 'guard', 'integer', 'ltValue', 'maxValue', diff --git a/website/src/routes/api/(schemas)/objectWithRest/index.mdx b/website/src/routes/api/(schemas)/objectWithRest/index.mdx index bdb800ece..be6199926 100644 --- a/website/src/routes/api/(schemas)/objectWithRest/index.mdx +++ b/website/src/routes/api/(schemas)/objectWithRest/index.mdx @@ -203,6 +203,7 @@ The following APIs can be combined with `objectWithRest`. 'description', 'entries', 'flavor', + 'guard', 'maxEntries', 'metadata', 'minEntries', diff --git a/website/src/routes/api/(schemas)/optional/index.mdx b/website/src/routes/api/(schemas)/optional/index.mdx index d661168c0..afb753d0a 100644 --- a/website/src/routes/api/(schemas)/optional/index.mdx +++ b/website/src/routes/api/(schemas)/optional/index.mdx @@ -165,6 +165,7 @@ The following APIs can be combined with `optional`. 'brand', 'description', 'flavor', + 'guard', 'metadata', 'partialCheck', 'rawCheck', diff --git a/website/src/routes/api/(schemas)/picklist/index.mdx b/website/src/routes/api/(schemas)/picklist/index.mdx index e3162d186..b0026ed60 100644 --- a/website/src/routes/api/(schemas)/picklist/index.mdx +++ b/website/src/routes/api/(schemas)/picklist/index.mdx @@ -131,6 +131,7 @@ The following APIs can be combined with `picklist`. 'brand', 'description', 'flavor', + 'guard', 'metadata', 'rawCheck', 'rawTransform', diff --git a/website/src/routes/api/(schemas)/promise/index.mdx b/website/src/routes/api/(schemas)/promise/index.mdx index 342848dfd..bcb7eca09 100644 --- a/website/src/routes/api/(schemas)/promise/index.mdx +++ b/website/src/routes/api/(schemas)/promise/index.mdx @@ -113,6 +113,7 @@ The following APIs can be combined with `promise`. 'brand', 'description', 'flavor', + 'guard', 'metadata', 'rawCheck', 'rawTransform', diff --git a/website/src/routes/api/(schemas)/record/index.mdx b/website/src/routes/api/(schemas)/record/index.mdx index e1f07e533..8eae8078e 100644 --- a/website/src/routes/api/(schemas)/record/index.mdx +++ b/website/src/routes/api/(schemas)/record/index.mdx @@ -177,6 +177,7 @@ The following APIs can be combined with `record`. 'description', 'entries', 'flavor', + 'guard', 'maxEntries', 'minEntries', 'metadata', diff --git a/website/src/routes/api/(schemas)/set/index.mdx b/website/src/routes/api/(schemas)/set/index.mdx index c977a74bd..09df4996b 100644 --- a/website/src/routes/api/(schemas)/set/index.mdx +++ b/website/src/routes/api/(schemas)/set/index.mdx @@ -140,6 +140,7 @@ The following APIs can be combined with `set`. 'brand', 'description', 'flavor', + 'guard', 'maxSize', 'metadata', 'minSize', diff --git a/website/src/routes/api/(schemas)/strictObject/index.mdx b/website/src/routes/api/(schemas)/strictObject/index.mdx index 9973fcc55..ac9e369e9 100644 --- a/website/src/routes/api/(schemas)/strictObject/index.mdx +++ b/website/src/routes/api/(schemas)/strictObject/index.mdx @@ -185,6 +185,7 @@ The following APIs can be combined with `strictObject`. 'description', 'entries', 'flavor', + 'guard', 'maxEntries', 'metadata', 'minEntries', diff --git a/website/src/routes/api/(schemas)/strictTuple/index.mdx b/website/src/routes/api/(schemas)/strictTuple/index.mdx index 49c51e949..4f5d6c25f 100644 --- a/website/src/routes/api/(schemas)/strictTuple/index.mdx +++ b/website/src/routes/api/(schemas)/strictTuple/index.mdx @@ -140,6 +140,7 @@ The following APIs can be combined with `strictTuple`. 'filterItems', 'findItem', 'flavor', + 'guard', 'includes', 'length', 'mapItems', diff --git a/website/src/routes/api/(schemas)/string/index.mdx b/website/src/routes/api/(schemas)/string/index.mdx index 28fa40904..e827152b2 100644 --- a/website/src/routes/api/(schemas)/string/index.mdx +++ b/website/src/routes/api/(schemas)/string/index.mdx @@ -157,6 +157,7 @@ The following APIs can be combined with `string`. 'flavor', 'graphemes', 'gtValue', + 'guard', 'hash', 'hexadecimal', 'hexColor', diff --git a/website/src/routes/api/(schemas)/symbol/index.mdx b/website/src/routes/api/(schemas)/symbol/index.mdx index 501541c62..99318e903 100644 --- a/website/src/routes/api/(schemas)/symbol/index.mdx +++ b/website/src/routes/api/(schemas)/symbol/index.mdx @@ -109,6 +109,7 @@ The following APIs can be combined with `symbol`. 'brand', 'description', 'flavor', + 'guard', 'metadata', 'rawCheck', 'rawTransform', diff --git a/website/src/routes/api/(schemas)/tuple/index.mdx b/website/src/routes/api/(schemas)/tuple/index.mdx index 56ba68c0d..21432913b 100644 --- a/website/src/routes/api/(schemas)/tuple/index.mdx +++ b/website/src/routes/api/(schemas)/tuple/index.mdx @@ -140,6 +140,7 @@ The following APIs can be combined with `tuple`. 'filterItems', 'findItem', 'flavor', + 'guard', 'includes', 'length', 'mapItems', diff --git a/website/src/routes/api/(schemas)/tupleWithRest/index.mdx b/website/src/routes/api/(schemas)/tupleWithRest/index.mdx index 1ca61d85c..624b5ac53 100644 --- a/website/src/routes/api/(schemas)/tupleWithRest/index.mdx +++ b/website/src/routes/api/(schemas)/tupleWithRest/index.mdx @@ -143,6 +143,7 @@ The following APIs can be combined with `tupleWithRest`. 'filterItems', 'findItem', 'flavor', + 'guard', 'includes', 'length', 'mapItems', diff --git a/website/src/routes/api/(schemas)/undefined/index.mdx b/website/src/routes/api/(schemas)/undefined/index.mdx index 08ea31cf3..b5aab8540 100644 --- a/website/src/routes/api/(schemas)/undefined/index.mdx +++ b/website/src/routes/api/(schemas)/undefined/index.mdx @@ -96,6 +96,7 @@ The following APIs can be combined with `undefined`. 'brand', 'description', 'flavor', + 'guard', 'metadata', 'rawCheck', 'rawTransform', diff --git a/website/src/routes/api/(schemas)/undefinedable/index.mdx b/website/src/routes/api/(schemas)/undefinedable/index.mdx index 2d32fcbe7..c1e5139b6 100644 --- a/website/src/routes/api/(schemas)/undefinedable/index.mdx +++ b/website/src/routes/api/(schemas)/undefinedable/index.mdx @@ -169,6 +169,7 @@ The following APIs can be combined with `undefinedable`. 'brand', 'description', 'flavor', + 'guard', 'metadata', 'partialCheck', 'rawCheck', diff --git a/website/src/routes/api/(schemas)/union/index.mdx b/website/src/routes/api/(schemas)/union/index.mdx index 4e4091516..d3730bf41 100644 --- a/website/src/routes/api/(schemas)/union/index.mdx +++ b/website/src/routes/api/(schemas)/union/index.mdx @@ -177,6 +177,7 @@ The following APIs can be combined with `union`. 'flavor', 'graphemes', 'gtValue', + 'guard', 'hash', 'hexadecimal', 'hexColor', diff --git a/website/src/routes/api/(schemas)/variant/index.mdx b/website/src/routes/api/(schemas)/variant/index.mdx index 8bbdaad4c..3c92124e1 100644 --- a/website/src/routes/api/(schemas)/variant/index.mdx +++ b/website/src/routes/api/(schemas)/variant/index.mdx @@ -151,6 +151,7 @@ The following APIs can be combined with `variant`. 'description', 'entries', 'flavor', + 'guard', 'maxEntries', 'metadata', 'minEntries', diff --git a/website/src/routes/api/(schemas)/void/index.mdx b/website/src/routes/api/(schemas)/void/index.mdx index 915ebda1e..ab16068db 100644 --- a/website/src/routes/api/(schemas)/void/index.mdx +++ b/website/src/routes/api/(schemas)/void/index.mdx @@ -96,6 +96,7 @@ The following APIs can be combined with `void`. 'brand', 'description', 'flavor', + 'guard', 'metadata', 'rawCheck', 'rawTransform', diff --git a/website/src/routes/api/(types)/GuardAction/index.mdx b/website/src/routes/api/(types)/GuardAction/index.mdx new file mode 100644 index 000000000..b1671dbae --- /dev/null +++ b/website/src/routes/api/(types)/GuardAction/index.mdx @@ -0,0 +1,27 @@ +--- +title: GuardAction +description: Guard action interface. +contributors: + - EskiMojo14 +--- + +import { Property } from '~/components'; +import { properties } from './properties'; + +# GuardAction + +Guard action interface. + +## Generics + +- `TInput` +- `TGuard` +- `TMessage` + +## Definition + +- `GuardAction` + - `type` + - `reference` + - `requirement` + - `message` diff --git a/website/src/routes/api/(types)/GuardAction/properties.ts b/website/src/routes/api/(types)/GuardAction/properties.ts new file mode 100644 index 000000000..8858885e6 --- /dev/null +++ b/website/src/routes/api/(types)/GuardAction/properties.ts @@ -0,0 +1,128 @@ +import type { PropertyProps } from '~/components'; + +export const properties: Record = { + TInput: { + modifier: 'extends', + type: 'any', + }, + TGuard: { + modifier: 'extends', + type: { + type: 'custom', + name: 'GuardFunction', + href: '../GuardFunction/', + generics: [ + { + type: 'custom', + name: 'TInput', + }, + ], + }, + }, + TMessage: { + modifier: 'extends', + type: { + type: 'union', + options: [ + { + type: 'custom', + name: 'ErrorMessage', + href: '../ErrorMessage/', + generics: [ + { + type: 'custom', + name: 'GuardIssue', + href: '../GuardIssue/', + generics: [ + { + type: 'custom', + name: 'TInput', + }, + { + type: 'custom', + name: 'TGuard', + }, + ], + }, + ], + }, + 'undefined', + ], + }, + }, + BaseTransformation: { + modifier: 'extends', + type: { + type: 'custom', + name: 'BaseTransformation', + href: '../BaseTransformation/', + generics: [ + { + type: 'custom', + name: 'TInput', + }, + { + type: 'intersect', + options: [ + { + type: 'custom', + name: 'TInput', + }, + { + type: 'custom', + name: 'InferGuardOutput', + href: '../InferGuardOutput/', + generics: [ + { + type: 'custom', + name: 'TGuard', + }, + ], + }, + ], + }, + { + type: 'custom', + name: 'GuardIssue', + href: '../GuardIssue/', + generics: [ + { + type: 'custom', + name: 'TInput', + }, + { + type: 'custom', + name: 'TGuard', + }, + ], + }, + ], + }, + }, + type: { + type: { + type: 'string', + value: 'guard', + }, + }, + reference: { + type: { + type: 'custom', + modifier: 'typeof', + name: 'guard', + href: '../guard/', + }, + }, + requirement: { + type: { + type: 'custom', + name: 'TGuard', + }, + }, + message: { + type: { + type: 'custom', + name: 'TMessage', + }, + }, +}; diff --git a/website/src/routes/api/(types)/GuardFunction/index.mdx b/website/src/routes/api/(types)/GuardFunction/index.mdx new file mode 100644 index 000000000..f2c8c5638 --- /dev/null +++ b/website/src/routes/api/(types)/GuardFunction/index.mdx @@ -0,0 +1,21 @@ +--- +title: GuardFunction +description: Guard function type. +contributors: + - fabian-hiller +--- + +import { Property } from '~/components'; +import { properties } from './properties'; + +# GuardFunction + +Guard function type. + +## Generics + +- `TInput` + +## Definition + +- `GuardFunction` diff --git a/website/src/routes/api/(types)/GuardFunction/properties.ts b/website/src/routes/api/(types)/GuardFunction/properties.ts new file mode 100644 index 000000000..21f8d0d3f --- /dev/null +++ b/website/src/routes/api/(types)/GuardFunction/properties.ts @@ -0,0 +1,27 @@ +import type { PropertyProps } from '~/components'; + +export const properties: Record = { + TInput: { + modifier: 'extends', + type: 'any', + }, + GuardFunction: { + type: { + type: 'function', + params: [ + { + name: 'input', + type: { + type: 'custom', + name: 'TInput', + }, + }, + ], + return: { + type: 'predicate', + param: 'input', + is: 'any', + }, + }, + }, +}; diff --git a/website/src/routes/api/(types)/GuardIssue/index.mdx b/website/src/routes/api/(types)/GuardIssue/index.mdx new file mode 100644 index 000000000..e06ca1fef --- /dev/null +++ b/website/src/routes/api/(types)/GuardIssue/index.mdx @@ -0,0 +1,25 @@ +--- +title: GuardIssue +description: Guard issue interface. +contributors: + - EskiMojo14 +--- + +import { Property } from '~/components'; +import { properties } from './properties'; + +# GuardIssue + +Guard issue interface. + +## Generics + +- `TInput` +- `TGuard` + +## Definition + +- `GuardIssue` + - `kind` + - `type` + - `requirement` diff --git a/website/src/routes/api/(types)/GuardIssue/properties.ts b/website/src/routes/api/(types)/GuardIssue/properties.ts new file mode 100644 index 000000000..680cdf790 --- /dev/null +++ b/website/src/routes/api/(types)/GuardIssue/properties.ts @@ -0,0 +1,54 @@ +import type { PropertyProps } from '~/components'; + +export const properties: Record = { + TInput: { + modifier: 'extends', + type: 'any', + }, + TGuard: { + modifier: 'extends', + type: { + type: 'custom', + name: 'GuardFunction', + href: '../GuardFunction/', + generics: [ + { + type: 'custom', + name: 'TInput', + }, + ], + }, + }, + BaseIssue: { + modifier: 'extends', + type: { + type: 'custom', + name: 'BaseIssue', + href: '../BaseIssue/', + generics: [ + { + type: 'custom', + name: 'TInput', + }, + ], + }, + }, + kind: { + type: { + type: 'string', + value: 'transformation', + }, + }, + type: { + type: { + type: 'string', + value: 'guard', + }, + }, + requirement: { + type: { + type: 'custom', + name: 'TGuard', + }, + }, +}; diff --git a/website/src/routes/api/(types)/InferGuardOutput/index.mdx b/website/src/routes/api/(types)/InferGuardOutput/index.mdx new file mode 100644 index 000000000..fd671405f --- /dev/null +++ b/website/src/routes/api/(types)/InferGuardOutput/index.mdx @@ -0,0 +1,21 @@ +--- +title: InferGuardOutput +description: Infer guard output type. +contributors: + - fabian-hiller +--- + +import { Property } from '~/components'; +import { properties } from './properties'; + +# InferGuardOutput + +Infer guard output type. + +## Generics + +- `TGuard` + +## Definition + +- `InferGuardOutput` diff --git a/website/src/routes/api/(types)/InferGuardOutput/properties.ts b/website/src/routes/api/(types)/InferGuardOutput/properties.ts new file mode 100644 index 000000000..aac10fd93 --- /dev/null +++ b/website/src/routes/api/(types)/InferGuardOutput/properties.ts @@ -0,0 +1,49 @@ +import type { PropertyProps } from '~/components'; + +export const properties: Record = { + TGuard: { + modifier: 'extends', + type: { + type: 'custom', + name: 'GuardFunction', + href: '../GuardFunction/', + generics: ['any'], + }, + }, + InferGuardOutput: { + type: { + type: 'conditional', + conditions: [ + { + type: { + type: 'custom', + name: 'TGuard', + }, + extends: { + type: 'function', + params: [ + { + name: 'input', + type: 'any', + }, + ], + return: { + type: 'predicate', + param: 'input', + is: { + type: 'custom', + modifier: 'infer', + name: 'TOutput', + }, + }, + }, + true: { + type: 'custom', + name: 'TOutput', + }, + }, + ], + false: 'unknown', + }, + }, +}; diff --git a/website/src/routes/api/menu.md b/website/src/routes/api/menu.md index b3c6eafc4..e61c5f3db 100644 --- a/website/src/routes/api/menu.md +++ b/website/src/routes/api/menu.md @@ -107,6 +107,7 @@ - [flavor](/api/flavor/) - [graphemes](/api/graphemes/) - [gtValue](/api/gtValue/) +- [guard](/api/guard/) - [hash](/api/hash/) - [hexadecimal](/api/hexadecimal/) - [hexColor](/api/hexColor/) @@ -387,6 +388,9 @@ - [GraphemesIssue](/api/GraphemesIssue/) - [GtValueAction](/api/GtValueAction/) - [GtValueIssue](/api/GtValueIssue/) +- [GuardAction](/api/GuardAction/) +- [GuardFunction](/api/GuardFunction/) +- [GuardIssue](/api/GuardIssue/) - [HashAction](/api/HashAction/) - [HashIssue](/api/HashIssue/) - [HashType](/api/HashType/) @@ -403,6 +407,7 @@ - [InferExamples](/api/InferExamples/) - [InferFallback](/api/InferFallback/) - [InferFallbacks](/api/InferFallbacks/) +- [InferGuardOutput](/api/InferGuardOutput/) - [InferInput](/api/InferInput/) - [InferIntersectInput](/api/InferIntersectInput/) - [InferIntersectOutput](/api/InferIntersectOutput/) diff --git a/website/src/routes/guides/(main-concepts)/pipelines/index.mdx b/website/src/routes/guides/(main-concepts)/pipelines/index.mdx index 06f318270..607555717 100644 --- a/website/src/routes/guides/(main-concepts)/pipelines/index.mdx +++ b/website/src/routes/guides/(main-concepts)/pipelines/index.mdx @@ -171,6 +171,7 @@ Pipeline transformation actions allow to change the value and data type of the i 'filterItems', 'findItem', 'flavor', + 'guard', 'mapItems', 'rawTransform', 'readonly',