Skip to content

Commit

Permalink
Update API reference of actions on website
Browse files Browse the repository at this point in the history
  • Loading branch information
fabian-hiller committed May 26, 2024
1 parent efebaf9 commit 2bdb2c8
Show file tree
Hide file tree
Showing 122 changed files with 2,600 additions and 1,177 deletions.
4 changes: 2 additions & 2 deletions library/src/actions/bytes/bytes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export interface BytesAction<
}

/**
* Creates a bytes validation action.
* Creates a [bytes](https://en.wikipedia.org/wiki/Byte) validation action.
*
* @param requirement The required bytes.
*
Expand All @@ -74,7 +74,7 @@ export function bytes<TInput extends string, const TRequirement extends number>(
): BytesAction<TInput, TRequirement, undefined>;

/**
* Creates a bytes validation action.
* Creates a [bytes](https://en.wikipedia.org/wiki/Byte) validation action.
*
* @param requirement The required bytes.
* @param message The error message.
Expand Down
4 changes: 2 additions & 2 deletions library/src/actions/creditCard/creditCard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ const PROVIDER_REGEX_LIST = [
];

/**
* Creates a credit card validation action.
* Creates a [credit card](https://en.wikipedia.org/wiki/Payment_card_number) validation action.
*
* @returns A Credit card action.
*/
Expand All @@ -104,7 +104,7 @@ export function creditCard<TInput extends string>(): CreditCardAction<
>;

/**
* Creates a credit card validation action.
* Creates a [credit card](https://en.wikipedia.org/wiki/Payment_card_number) validation action.
*
* @param message The error message.
*
Expand Down
4 changes: 2 additions & 2 deletions library/src/actions/cuid2/cuid2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,14 @@ export interface Cuid2Action<
}

/**
* Creates a Cuid2 validation action.
* Creates a [Cuid2](https://github.com/paralleldrive/cuid2) validation action.
*
* @returns A Cuid2 action.
*/
export function cuid2<TInput extends string>(): Cuid2Action<TInput, undefined>;

/**
* Creates a Cuid2 validation action.
* Creates a [Cuid2](https://github.com/paralleldrive/cuid2) validation action.
*
* @param message The error message.
*
Expand Down
14 changes: 12 additions & 2 deletions library/src/actions/email/email.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,24 @@ export interface EmailAction<
}

/**
* Creates an email validation action.
* Creates an [email](https://en.wikipedia.org/wiki/Email_address) validation
* action.
*
* Hint: This validation action intentionally only validates common email
* addresses. If you are interested in an action that covers the entire
* specification, please see issue [#204](https://github.com/fabian-hiller/valibot/issues/204).
*
* @returns An email action.
*/
export function email<TInput extends string>(): EmailAction<TInput, undefined>;

/**
* Creates an email validation action.
* Creates an [email](https://en.wikipedia.org/wiki/Email_address) validation
* action.
*
* Hint: This validation action intentionally only validates common email
* addresses. If you are interested in an action that covers the entire
* specification, please see issue [#204](https://github.com/fabian-hiller/valibot/issues/204).
*
* @param message The error message.
*
Expand Down
4 changes: 2 additions & 2 deletions library/src/actions/emoji/emoji.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,14 @@ export interface EmojiAction<
}

/**
* Creates an emoji validation action.
* Creates an [emoji](https://en.wikipedia.org/wiki/Emoji) validation action.
*
* @returns An emoji action.
*/
export function emoji<TInput extends string>(): EmojiAction<TInput, undefined>;

/**
* Creates an emoji validation action.
* Creates an [emoji](https://en.wikipedia.org/wiki/Emoji) validation action.
*
* @param message The error message.
*
Expand Down
4 changes: 2 additions & 2 deletions library/src/actions/finite/finite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export interface FiniteAction<
}

/**
* Creates a finite validation action.
* Creates a [finite](https://en.wikipedia.org/wiki/Finite) validation action.
*
* @returns A finite action.
*/
Expand All @@ -72,7 +72,7 @@ export function finite<TInput extends number>(): FiniteAction<
>;

/**
* Creates a finite validation action.
* Creates a [finite](https://en.wikipedia.org/wiki/Finite) validation action.
*
* @param message The error message.
*
Expand Down
4 changes: 2 additions & 2 deletions library/src/actions/hash/hash.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export interface HashAction<
}

/**
* Creates a hash validation action.
* Creates a [hash](https://en.wikipedia.org/wiki/Hash_function) validation action.
*
* @param types The hash types.
*
Expand All @@ -98,7 +98,7 @@ export function hash<TInput extends string>(
): HashAction<TInput, undefined>;

/**
* Creates a hash validation action.
* Creates a [hash](https://en.wikipedia.org/wiki/Hash_function) validation action.
*
* @param types The hash types.
* @param message The error message.
Expand Down
8 changes: 4 additions & 4 deletions library/src/actions/integer/integer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,21 +62,21 @@ export interface IntegerAction<
}

/**
* Creates a integer validation action.
* Creates an [integer](https://en.wikipedia.org/wiki/Integer) validation action.
*
* @returns A integer action.
* @returns An integer action.
*/
export function integer<TInput extends number>(): IntegerAction<
TInput,
undefined
>;

/**
* Creates a integer validation action.
* Creates an [integer](https://en.wikipedia.org/wiki/Integer) validation action.
*
* @param message The error message.
*
* @returns A integer action.
* @returns An integer action.
*/
export function integer<
TInput extends number,
Expand Down
4 changes: 2 additions & 2 deletions library/src/actions/isoTimestamp/isoTimestamp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export interface IsoTimestampAction<
* specification can be removed or contain up to 9 digits.
*
* Hint: The regex used cannot validate the maximum number of days based on
* year and month. For example, `"2023-06-31T00:00:00.000Z"` is valid although
* year and month. For example, "2023-06-31T00:00:00.000Z" is valid although
* June has only 30 days.
*
* @returns An ISO timestamp action.
Expand All @@ -100,7 +100,7 @@ export function isoTimestamp<TInput extends string>(): IsoTimestampAction<
* specification can be removed or contain up to 9 digits.
*
* Hint: The regex used cannot validate the maximum number of days based on
* year and month. For example, `"2023-06-31T00:00:00.000Z"` is valid although
* year and month. For example, "2023-06-31T00:00:00.000Z" is valid although
* June has only 30 days.
*
* @param message The error message.
Expand Down
4 changes: 2 additions & 2 deletions library/src/actions/maxBytes/maxBytes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export interface MaxBytesAction<
}

/**
* Creates a max bytes validation action.
* Creates a max [bytes](https://en.wikipedia.org/wiki/Byte) validation action.
*
* @param requirement The maximum bytes.
*
Expand All @@ -79,7 +79,7 @@ export function maxBytes<
>(requirement: TRequirement): MaxBytesAction<TInput, TRequirement, undefined>;

/**
* Creates a max bytes validation action.
* Creates a max [bytes](https://en.wikipedia.org/wiki/Byte) validation action.
*
* @param requirement The maximum bytes.
* @param message The error message.
Expand Down
4 changes: 2 additions & 2 deletions library/src/actions/minBytes/minBytes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export interface MinBytesAction<
}

/**
* Creates a min bytes validation action.
* Creates a min [bytes](https://en.wikipedia.org/wiki/Byte) validation action.
*
* @param requirement The minimum bytes.
*
Expand All @@ -79,7 +79,7 @@ export function minBytes<
>(requirement: TRequirement): MinBytesAction<TInput, TRequirement, undefined>;

/**
* Creates a min bytes validation action.
* Creates a min [bytes](https://en.wikipedia.org/wiki/Byte) validation action.
*
* @param requirement The minimum bytes.
* @param message The error message.
Expand Down
4 changes: 2 additions & 2 deletions library/src/actions/multipleOf/multipleOf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export interface MultipleOfAction<
}

/**
* Creates a multiple of validation action.
* Creates a [multiple](https://en.wikipedia.org/wiki/Multiple_(mathematics)) of validation action.
*
* @param requirement The divisor.
*
Expand All @@ -83,7 +83,7 @@ export function multipleOf<
>(requirement: TRequirement): MultipleOfAction<TInput, TRequirement, undefined>;

/**
* Creates a multiple of validation action.
* Creates a [multiple](https://en.wikipedia.org/wiki/Multiple_(mathematics)) of validation action.
*
* @param requirement The divisor.
* @param message The error message.
Expand Down
4 changes: 2 additions & 2 deletions library/src/actions/notBytes/notBytes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export interface NotBytesAction<
}

/**
* Creates a not bytes validation action.
* Creates a not [bytes](https://en.wikipedia.org/wiki/Byte) validation action.
*
* @param requirement The not required bytes.
*
Expand All @@ -79,7 +79,7 @@ export function notBytes<
>(requirement: TRequirement): NotBytesAction<TInput, TRequirement, undefined>;

/**
* Creates a not bytes validation action.
* Creates a not [bytes](https://en.wikipedia.org/wiki/Byte) validation action.
*
* @param requirement The not required bytes.
* @param message The error message.
Expand Down
4 changes: 2 additions & 2 deletions library/src/actions/regex/regex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export interface RegexAction<
}

/**
* Creates a regex validation action.
* Creates a [regex](https://en.wikipedia.org/wiki/Regular_expression) validation action.
*
* @param requirement The regex pattern.
*
Expand All @@ -73,7 +73,7 @@ export function regex<TInput extends string>(
): RegexAction<TInput, undefined>;

/**
* Creates a regex validation action.
* Creates a [regex](https://en.wikipedia.org/wiki/Regular_expression) validation action.
*
* @param requirement The regex pattern.
* @param message The error message.
Expand Down
19 changes: 14 additions & 5 deletions website/src/routes/api/(actions)/bic/index.mdx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: bic
description: Creates a pipeline validation action that validates a BIC.
description: Creates a BIC validation action.
source: /actions/bic/bic.ts
contributors:
- fabian-hiller
Expand All @@ -12,15 +12,16 @@ import { properties } from './properties';

# bic

Creates a pipeline validation action that validates a [BIC](https://en.wikipedia.org/wiki/ISO_9362).
Creates a [BIC](https://en.wikipedia.org/wiki/ISO_9362) validation action.

```ts
const Validation = bic<TInput>(message);
const Action = bic<TInput, TMessage>(message);
```

## Generics

- `TInput` <Property {...properties.TInput} />
- `TMessage` <Property {...properties.TMessage} />

## Parameters

Expand All @@ -32,7 +33,7 @@ With `bic` you can validate the formatting of a string. If the input is not a BI

## Returns

- `Validation` <Property {...properties.Validation} />
- `Action` <Property {...properties.Action} />

## Examples

Expand All @@ -43,7 +44,11 @@ The following examples show how `bic` can be used.
Schema to validate a BIC.

```ts
const BicSchema = string([toUpperCase(), bic('The BIC is badly formatted.')]);
const BicSchema = v.pipe(
v.string(),
v.toUpperCase(),
v.bic('The BIC is badly formatted.')
);
```

## Related
Expand All @@ -53,3 +58,7 @@ The following APIs can be combined with `bic`.
### Schemas

<ApiList items={['any', 'special', 'string', 'unknown']} />

### Methods

<ApiList items={['pipe']} />
32 changes: 28 additions & 4 deletions website/src/routes/api/(actions)/bic/properties.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,53 @@ export const properties: Record<string, PropertyProps> = {
modifier: 'extends',
type: 'string',
},
message: {
TMessage: {
modifier: 'extends',
type: {
type: 'union',
options: [
{
type: 'custom',
name: 'ErrorMessage',
href: '../ErrorMessage/',
generics: [
{
type: 'custom',
name: 'BicIssue',
href: '../BicIssue/',
generics: [
{
type: 'custom',
name: 'TInput',
},
],
},
],
},
'undefined',
],
},
},
Validation: {
message: {
type: {
type: 'custom',
name: 'TMessage',
},
},
Action: {
type: {
type: 'custom',
name: 'BicValidation',
href: '../BicValidation/',
name: 'BicAction',
href: '../BicAction/',
generics: [
{
type: 'custom',
name: 'TInput',
},
{
type: 'custom',
name: 'TMessage',
},
],
},
},
Expand Down
Loading

0 comments on commit 2bdb2c8

Please sign in to comment.