Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: octal validation #415

Merged
merged 2 commits into from
Feb 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion library/src/validations/octal/octal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export type OctalValidation<TInput extends string> = BaseValidation<TInput> & {
};

/**
* Creates a pipeline validation action that validates an [octal](https://en.wikipedia.org/wiki/Octal) string.
* Creates a pipeline validation action that validates an [octal](https://en.wikipedia.org/wiki/Octal).
*
* @param message The error message.
*
Expand Down
23 changes: 23 additions & 0 deletions website/src/routes/api/(types)/OctalValidation/index.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
title: OctalValidation
description: Octal validation type.
contributors:
- fabian-hiller
---

import { Property } from '~/components';
import { properties } from './properties';

# OctalValidation

Octal validation type.

## Generics

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

## Definition

- `OctalValidation` <Property {...properties.BaseValidation} />
- `type` <Property {...properties.type} />
- `requirement` <Property {...properties.requirement} />
33 changes: 33 additions & 0 deletions website/src/routes/api/(types)/OctalValidation/properties.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import type { PropertyProps } from '~/components';

export const properties: Record<string, PropertyProps> = {
TInput: {
modifier: 'extends',
type: 'string',
},
BaseValidation: {
type: {
type: 'custom',
name: 'BaseValidation',
href: '../BaseValidation/',
generics: [
{
type: 'custom',
name: 'TInput',
},
],
},
},
type: {
type: {
type: 'string',
value: 'octal',
},
},
requirement: {
type: {
type: 'custom',
name: 'RegExp',
},
},
};
46 changes: 45 additions & 1 deletion website/src/routes/api/(validations)/octal/index.mdx
Original file line number Diff line number Diff line change
@@ -1,11 +1,55 @@
---
title: octal
description: Creates a pipeline validation action that validates an octal.
source: /validations/octal/octal.ts
contributors:
- fabian-hiller
- ariskemper
---

import { ApiList, Property } from '~/components';
import { properties } from './properties';

# octal

> The content of this page is not yet ready. Until then, please use the [source code](https://github.com/fabian-hiller/valibot/blob/main/library/src/validations/octal/octal.ts) or take a look at [issue #287](https://github.com/fabian-hiller/valibot/issues/287) to help us extend the API reference.
Creates a pipeline validation action that validates an [octal](https://en.wikipedia.org/wiki/Octal).

```ts
const validation = octal<TInput>(message);
```

## Generics

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

## Parameters

- `message` <Property {...properties.message} />

### Explanation

With `octal` you can validate the formatting of a string. If the input is not an octal, you can use `message` to customize the error message.

## Returns

- `validation` <Property {...properties.validation} />

## Examples

The following examples show how `octal` can be used.

### Octal schema

Schema to validate a octal string.

```ts
const OctalSchema = string([octal('The octal is badly formatted.')]);
```

## Related

The following APIs can be combined with `octal`.

### Schemas

<ApiList items={['any', 'string', 'unknown']} />
28 changes: 28 additions & 0 deletions website/src/routes/api/(validations)/octal/properties.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import type { PropertyProps } from '~/components';

export const properties: Record<string, PropertyProps> = {
TInput: {
modifier: 'extends',
type: 'string',
},
message: {
type: {
type: 'union',
options: [
{
type: 'custom',
name: 'ErrorMessage',
href: '../ErrorMessage/',
},
'undefined',
],
},
},
validation: {
type: {
type: 'custom',
name: 'OctalValidation',
href: '../OctalValidation/',
},
},
};
1 change: 1 addition & 0 deletions website/src/routes/api/menu.md
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,7 @@
- [ObjectOutput](/api/ObjectOutput/)
- [ObjectPathItem](/api/ObjectPathItem/)
- [ObjectSchema](/api/ObjectSchema/)
- [OctalValidation](/api/OctalValidation/)
- [OptionalSchema](/api/OptionalSchema/)
- [Output](/api/Output/)
- [ParseInfo](/api/ParseInfo/)
Expand Down
Loading