Skip to content

Commit

Permalink
Merge pull request #415 from ariskemper/docs-octal-validation
Browse files Browse the repository at this point in the history
docs: octal validation
  • Loading branch information
fabian-hiller committed Feb 10, 2024
2 parents eaac7b6 + a9946f2 commit ecf44d8
Show file tree
Hide file tree
Showing 6 changed files with 131 additions and 2 deletions.
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 @@ -269,6 +269,7 @@
- [ObjectOutput](/api/ObjectOutput/)
- [ObjectPathItem](/api/ObjectPathItem/)
- [ObjectSchema](/api/ObjectSchema/)
- [OctalValidation](/api/OctalValidation/)
- [OptionalSchema](/api/OptionalSchema/)
- [Output](/api/Output/)
- [PathItem](/api/PathItem/)
Expand Down

0 comments on commit ecf44d8

Please sign in to comment.