Filters
Developers can define custom validation logic beyond basic type checks, giving more control over how data is validated.
Filters are declared using the Schema.filter
function. This function requires two arguments: the schema to be validated and a predicate function. The predicate function is user-defined and determines whether the data satisfies the condition. If the data fails the validation, an error message can be provided.
Example
1import { import Schema
Schema } from "effect"2
3// Define a string schema with a filter to ensure the string4// is at least 10 characters long5const const LongString: Schema.filter<typeof Schema.String>
LongString = import Schema
Schema.(alias) class String
export String
String.(method) Pipeable.pipe<typeof Schema.String, Schema.filter<typeof Schema.String>>(this: typeof Schema.String, ab: (_: typeof Schema.String) => Schema.filter<typeof Schema.String>): Schema.filter<...> (+21 overloads)
pipe(6 import Schema
Schema.function filter<typeof Schema.String>(predicate: (a: string, options: ParseOptions, self: Refinement) => FilterReturnType, annotations?: Schema.Annotations.Filter<...> | undefined): (self: typeof Schema.String) => Schema.filter<...> (+2 overloads)
filter(7 // Custom error message for strings shorter than 10 characters8 ((parameter) s: string
s) => (parameter) s: string
s.(property) String.length: number
Returns the length of a String object.
length >= 10 || "a string at least 10 characters long"9 )10)11
12// string13type type LongString = string
LongString = typeof const LongString: Schema.filter<typeof Schema.String>
LongString.(property) Schema<string, string, never>.Type: string
Type14
15namespace console
var console: Console
The `console` module provides a simple debugging console that is similar to the
JavaScript console mechanism provided by web browsers.
The module exports two specific components:
* A `Console` class with methods such as `console.log()`, `console.error()` and `console.warn()` that can be used to write to any Node.js stream.
* A global `console` instance configured to write to [`process.stdout`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstdout) and
[`process.stderr`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstderr). The global `console` can be used without importing the `node:console` module.
_**Warning**_: The global console object's methods are neither consistently
synchronous like the browser APIs they resemble, nor are they consistently
asynchronous like all other Node.js streams. See the [`note on process I/O`](https://nodejs.org/docs/latest-v22.x/api/process.html#a-note-on-process-io) for
more information.
Example using the global `console`:
```js
console.log('hello world');
// Prints: hello world, to stdout
console.log('hello %s', 'world');
// Prints: hello world, to stdout
console.error(new Error('Whoops, something bad happened'));
// Prints error message and stack trace to stderr:
// Error: Whoops, something bad happened
// at [eval]:5:15
// at Script.runInThisContext (node:vm:132:18)
// at Object.runInThisContext (node:vm:309:38)
// at node:internal/process/execution:77:19
// at [eval]-wrapper:6:22
// at evalScript (node:internal/process/execution:76:60)
// at node:internal/main/eval_string:23:3
const name = 'Will Robinson';
console.warn(`Danger ${name}! Danger!`);
// Prints: Danger Will Robinson! Danger!, to stderr
```
Example using the `Console` class:
```js
const out = getStreamSomehow();
const err = getStreamSomehow();
const myConsole = new console.Console(out, err);
myConsole.log('hello world');
// Prints: hello world, to out
myConsole.log('hello %s', 'world');
// Prints: hello world, to out
myConsole.error(new Error('Whoops, something bad happened'));
// Prints: [Error: Whoops, something bad happened], to err
const name = 'Will Robinson';
myConsole.warn(`Danger ${name}! Danger!`);
// Prints: Danger Will Robinson! Danger!, to err
```
console.(method) Console.log(message?: any, ...optionalParams: any[]): void
Prints to `stdout` with newline. Multiple arguments can be passed, with the
first used as the primary message and all additional used as substitution
values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html)
(the arguments are all passed to [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args)).
```js
const count = 5;
console.log('count: %d', count);
// Prints: count: 5, to stdout
console.log('count:', count);
// Prints: count: 5, to stdout
```
See [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args) for more information.
log(import Schema
Schema.(alias) decodeUnknownSync<string, string>(schema: Schema.Schema<string, string, never>, options?: ParseOptions): (u: unknown, overrideOptions?: ParseOptions) => string
export decodeUnknownSync
decodeUnknownSync(const LongString: Schema.filter<typeof Schema.String>
LongString)("a"))16/*17throws:18ParseError: { string | filter }19└─ Predicate refinement failure20 └─ a string at least 10 characters long21*/
Note that the filter does not modify the schema’s Type
:
// stringtype LongString = typeof LongString.Type
Filters add additional validation constraints but do not alter the schema’s underlying type.
The predicate function in a filter follows this structure:
1type Predicate = (2 a: A,3 options: ParseOptions,4 self: AST.Refinement5) => FilterReturnType
where
1interface FilterIssue {2 readonly path: ReadonlyArray<PropertyKey>3 readonly issue: string | ParseResult.ParseIssue4}5
6type FilterOutput =7 | undefined8 | boolean9 | string10 | ParseResult.ParseIssue11 | FilterIssue12
13type FilterReturnType = FilterOutput | ReadonlyArray<FilterOutput>
The filter’s predicate can return several types of values, each affecting validation in a different way:
Return Type | Behavior |
---|---|
true | The data satisfies the filter’s condition and passes validation. |
false or undefined | The data does not meet the condition, and no specific error message is provided. |
string | The validation fails, and the provided string is used as the error message. |
ParseResult.ParseIssue | The validation fails with a detailed error structure, specifying where and why it failed. |
FilterIssue | Allows for more detailed error messages with specific paths, providing enhanced error reporting. |
ReadonlyArray<FilterOutput> | An array of issues can be returned if multiple validation errors need to be reported. |
It’s beneficial to embed as much metadata as possible within the schema. This metadata can include identifiers, JSON schema specifications, and descriptive text to facilitate later analysis and understanding of the schema’s purpose and constraints.
Example
1import { import Schema
Schema, import JSONSchema
JSONSchema } from "effect"2
3const const LongString: Schema.filter<typeof Schema.String>
LongString = import Schema
Schema.(alias) class String
export String
String.(method) Pipeable.pipe<typeof Schema.String, Schema.filter<typeof Schema.String>>(this: typeof Schema.String, ab: (_: typeof Schema.String) => Schema.filter<typeof Schema.String>): Schema.filter<...> (+21 overloads)
pipe(4 import Schema
Schema.function filter<typeof Schema.String>(predicate: (a: string, options: ParseOptions, self: Refinement) => FilterReturnType, annotations?: Schema.Annotations.Filter<...> | undefined): (self: typeof Schema.String) => Schema.filter<...> (+2 overloads)
filter(5 ((parameter) s: string
s) =>6 (parameter) s: string
s.(property) String.length: number
Returns the length of a String object.
length >= 10 ? var undefined
undefined : "a string at least 10 characters long",7 {8 (property) Annotations.Schema<A, TypeParameters extends ReadonlyArray<any> = readonly []>.identifier?: string
identifier: "LongString",9 (property) Annotations.Schema<A, TypeParameters extends ReadonlyArray<any> = readonly []>.jsonSchema?: object
jsonSchema: { (property) minLength: number
minLength: 10 },10 (property) Annotations.Doc<A>.description?: string
description: "Lorem ipsum dolor sit amet, ..."11 }12 )13)14
15namespace console
var console: Console
The `console` module provides a simple debugging console that is similar to the
JavaScript console mechanism provided by web browsers.
The module exports two specific components:
* A `Console` class with methods such as `console.log()`, `console.error()` and `console.warn()` that can be used to write to any Node.js stream.
* A global `console` instance configured to write to [`process.stdout`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstdout) and
[`process.stderr`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstderr). The global `console` can be used without importing the `node:console` module.
_**Warning**_: The global console object's methods are neither consistently
synchronous like the browser APIs they resemble, nor are they consistently
asynchronous like all other Node.js streams. See the [`note on process I/O`](https://nodejs.org/docs/latest-v22.x/api/process.html#a-note-on-process-io) for
more information.
Example using the global `console`:
```js
console.log('hello world');
// Prints: hello world, to stdout
console.log('hello %s', 'world');
// Prints: hello world, to stdout
console.error(new Error('Whoops, something bad happened'));
// Prints error message and stack trace to stderr:
// Error: Whoops, something bad happened
// at [eval]:5:15
// at Script.runInThisContext (node:vm:132:18)
// at Object.runInThisContext (node:vm:309:38)
// at node:internal/process/execution:77:19
// at [eval]-wrapper:6:22
// at evalScript (node:internal/process/execution:76:60)
// at node:internal/main/eval_string:23:3
const name = 'Will Robinson';
console.warn(`Danger ${name}! Danger!`);
// Prints: Danger Will Robinson! Danger!, to stderr
```
Example using the `Console` class:
```js
const out = getStreamSomehow();
const err = getStreamSomehow();
const myConsole = new console.Console(out, err);
myConsole.log('hello world');
// Prints: hello world, to out
myConsole.log('hello %s', 'world');
// Prints: hello world, to out
myConsole.error(new Error('Whoops, something bad happened'));
// Prints: [Error: Whoops, something bad happened], to err
const name = 'Will Robinson';
myConsole.warn(`Danger ${name}! Danger!`);
// Prints: Danger Will Robinson! Danger!, to err
```
console.(method) Console.log(message?: any, ...optionalParams: any[]): void
Prints to `stdout` with newline. Multiple arguments can be passed, with the
first used as the primary message and all additional used as substitution
values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html)
(the arguments are all passed to [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args)).
```js
const count = 5;
console.log('count: %d', count);
// Prints: count: 5, to stdout
console.log('count:', count);
// Prints: count: 5, to stdout
```
See [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args) for more information.
log(import Schema
Schema.(alias) decodeUnknownSync<string, string>(schema: Schema.Schema<string, string, never>, options?: ParseOptions): (u: unknown, overrideOptions?: ParseOptions) => string
export decodeUnknownSync
decodeUnknownSync(const LongString: Schema.filter<typeof Schema.String>
LongString)("a"))16/*17throws:18ParseError: LongString19└─ Predicate refinement failure20 └─ a string at least 10 characters long21*/22
23namespace console
var console: Console
The `console` module provides a simple debugging console that is similar to the
JavaScript console mechanism provided by web browsers.
The module exports two specific components:
* A `Console` class with methods such as `console.log()`, `console.error()` and `console.warn()` that can be used to write to any Node.js stream.
* A global `console` instance configured to write to [`process.stdout`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstdout) and
[`process.stderr`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstderr). The global `console` can be used without importing the `node:console` module.
_**Warning**_: The global console object's methods are neither consistently
synchronous like the browser APIs they resemble, nor are they consistently
asynchronous like all other Node.js streams. See the [`note on process I/O`](https://nodejs.org/docs/latest-v22.x/api/process.html#a-note-on-process-io) for
more information.
Example using the global `console`:
```js
console.log('hello world');
// Prints: hello world, to stdout
console.log('hello %s', 'world');
// Prints: hello world, to stdout
console.error(new Error('Whoops, something bad happened'));
// Prints error message and stack trace to stderr:
// Error: Whoops, something bad happened
// at [eval]:5:15
// at Script.runInThisContext (node:vm:132:18)
// at Object.runInThisContext (node:vm:309:38)
// at node:internal/process/execution:77:19
// at [eval]-wrapper:6:22
// at evalScript (node:internal/process/execution:76:60)
// at node:internal/main/eval_string:23:3
const name = 'Will Robinson';
console.warn(`Danger ${name}! Danger!`);
// Prints: Danger Will Robinson! Danger!, to stderr
```
Example using the `Console` class:
```js
const out = getStreamSomehow();
const err = getStreamSomehow();
const myConsole = new console.Console(out, err);
myConsole.log('hello world');
// Prints: hello world, to out
myConsole.log('hello %s', 'world');
// Prints: hello world, to out
myConsole.error(new Error('Whoops, something bad happened'));
// Prints: [Error: Whoops, something bad happened], to err
const name = 'Will Robinson';
myConsole.warn(`Danger ${name}! Danger!`);
// Prints: Danger Will Robinson! Danger!, to err
```
console.(method) Console.log(message?: any, ...optionalParams: any[]): void
Prints to `stdout` with newline. Multiple arguments can be passed, with the
first used as the primary message and all additional used as substitution
values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html)
(the arguments are all passed to [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args)).
```js
const count = 5;
console.log('count: %d', count);
// Prints: count: 5, to stdout
console.log('count:', count);
// Prints: count: 5, to stdout
```
See [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args) for more information.
log(import JSONSchema
JSONSchema.const make: <string, string, never>(schema: Schema.Schema<string, string, never>) => JSONSchema.JsonSchema7Root
make(const LongString: Schema.filter<typeof Schema.String>
LongString))24/*25Output:26{27 '$schema': 'http://json-schema.org/draft-07/schema#',28 type: 'string',29 description: 'Lorem ipsum dolor sit amet, ...',30 minLength: 1031}32*/
When validating forms or structured data, it’s possible to associate specific error messages with particular fields or paths. This enhances error reporting and is especially useful when integrating with libraries like react-hook-form.
Example (Match Passwords)
1import { import Either
Either, import Schema
Schema, import ParseResult
ParseResult } from "effect"2
3const const Password: Schema.filter<Schema.Schema<string, string, never>>
Password = import Schema
Schema.class Trim
This schema allows removing whitespaces from the beginning and end of a string.
Trim.(method) Pipeable.pipe<typeof Schema.Trim, Schema.filter<Schema.Schema<string, string, never>>>(this: typeof Schema.Trim, ab: (_: typeof Schema.Trim) => Schema.filter<Schema.Schema<string, string, never>>): Schema.filter<...> (+21 overloads)
pipe(import Schema
Schema.const minLength: <string>(minLength: number, annotations?: Schema.Annotations.Filter<string, string> | undefined) => <I, R>(self: Schema.Schema<string, I, R>) => Schema.filter<...>
minLength(2))4
5const const MyForm: Schema.filter<Schema.Struct<{
password: Schema.filter<Schema.Schema<string, string, never>>;
confirm_password: Schema.filter<Schema.Schema<string, string, never>>;
}>>
MyForm = import Schema
Schema.function Struct<{
password: Schema.filter<Schema.Schema<string, string, never>>;
confirm_password: Schema.filter<Schema.Schema<string, string, never>>;
}>(fields: {
...;
}): Schema.Struct<...> (+1 overload)
namespace Struct
Struct({6 (property) password: Schema.filter<Schema.Schema<string, string, never>>
password: const Password: Schema.filter<Schema.Schema<string, string, never>>
Password,7 (property) confirm_password: Schema.filter<Schema.Schema<string, string, never>>
confirm_password: const Password: Schema.filter<Schema.Schema<string, string, never>>
Password8}).(method) Pipeable.pipe<Schema.Struct<{
password: Schema.filter<Schema.Schema<string, string, never>>;
confirm_password: Schema.filter<Schema.Schema<string, string, never>>;
}>, Schema.filter<...>>(this: Schema.Struct<...>, ab: (_: Schema.Struct<...>) => Schema.filter<...>): Schema.filter<...> (+21 overloads)
pipe(9 // Add a filter to ensure that passwords match10 import Schema
Schema.function filter<Schema.Struct<{
password: Schema.filter<Schema.Schema<string, string, never>>;
confirm_password: Schema.filter<Schema.Schema<string, string, never>>;
}>>(predicate: (a: {
...;
}, options: ParseOptions, self: Refinement) => FilterReturnType, annotations?: Schema.Annotations.Filter<...> | undefined): (self: Schema.Struct<...>) => Schema.filter<...> (+2 overloads)
filter(((parameter) input: {
readonly password: string;
readonly confirm_password: string;
}
input) => {11 if ((parameter) input: {
readonly password: string;
readonly confirm_password: string;
}
input.(property) password: string
password !== (parameter) input: {
readonly password: string;
readonly confirm_password: string;
}
input.(property) confirm_password: string
confirm_password) {12 // Return an error message associated13 // with the "confirm_password" field14 return {15 (property) path: [string]
path: ["confirm_password"],16 (property) message: string
message: "Passwords do not match"17 }18 }19 })20)21
22namespace console
var console: Console
The `console` module provides a simple debugging console that is similar to the
JavaScript console mechanism provided by web browsers.
The module exports two specific components:
* A `Console` class with methods such as `console.log()`, `console.error()` and `console.warn()` that can be used to write to any Node.js stream.
* A global `console` instance configured to write to [`process.stdout`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstdout) and
[`process.stderr`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstderr). The global `console` can be used without importing the `node:console` module.
_**Warning**_: The global console object's methods are neither consistently
synchronous like the browser APIs they resemble, nor are they consistently
asynchronous like all other Node.js streams. See the [`note on process I/O`](https://nodejs.org/docs/latest-v22.x/api/process.html#a-note-on-process-io) for
more information.
Example using the global `console`:
```js
console.log('hello world');
// Prints: hello world, to stdout
console.log('hello %s', 'world');
// Prints: hello world, to stdout
console.error(new Error('Whoops, something bad happened'));
// Prints error message and stack trace to stderr:
// Error: Whoops, something bad happened
// at [eval]:5:15
// at Script.runInThisContext (node:vm:132:18)
// at Object.runInThisContext (node:vm:309:38)
// at node:internal/process/execution:77:19
// at [eval]-wrapper:6:22
// at evalScript (node:internal/process/execution:76:60)
// at node:internal/main/eval_string:23:3
const name = 'Will Robinson';
console.warn(`Danger ${name}! Danger!`);
// Prints: Danger Will Robinson! Danger!, to stderr
```
Example using the `Console` class:
```js
const out = getStreamSomehow();
const err = getStreamSomehow();
const myConsole = new console.Console(out, err);
myConsole.log('hello world');
// Prints: hello world, to out
myConsole.log('hello %s', 'world');
// Prints: hello world, to out
myConsole.error(new Error('Whoops, something bad happened'));
// Prints: [Error: Whoops, something bad happened], to err
const name = 'Will Robinson';
myConsole.warn(`Danger ${name}! Danger!`);
// Prints: Danger Will Robinson! Danger!, to err
```
console.(method) Console.log(message?: any, ...optionalParams: any[]): void
Prints to `stdout` with newline. Multiple arguments can be passed, with the
first used as the primary message and all additional used as substitution
values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html)
(the arguments are all passed to [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args)).
```js
const count = 5;
console.log('count: %d', count);
// Prints: count: 5, to stdout
console.log('count:', count);
// Prints: count: 5, to stdout
```
See [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args) for more information.
log(23 var JSON: JSON
An intrinsic object that provides functions to convert JavaScript values to and from the JavaScript Object Notation (JSON) format.
JSON.(method) JSON.stringify(value: any, replacer?: (number | string)[] | null, space?: string | number): string (+1 overload)
Converts a JavaScript value to a JavaScript Object Notation (JSON) string.
stringify(24 import Schema
Schema.const decodeUnknownEither: <{
readonly password: string;
readonly confirm_password: string;
}, {
readonly password: string;
readonly confirm_password: string;
}>(schema: Schema.Schema<{
readonly password: string;
readonly confirm_password: string;
}, {
...;
}, never>, options?: ParseOptions) => (u: unknown, overrideOptions?: ParseOptions) => Either.Either<...>
decodeUnknownEither(const MyForm: Schema.filter<Schema.Struct<{
password: Schema.filter<Schema.Schema<string, string, never>>;
confirm_password: Schema.filter<Schema.Schema<string, string, never>>;
}>>
MyForm)({25 (property) password: string
password: "abc",26 (property) confirm_password: string
confirm_password: "d" // Confirm password does not match27 }).(method) Pipeable.pipe<Either.Either<{
readonly password: string;
readonly confirm_password: string;
}, ParseResult.ParseError>, Either.Either<{
readonly password: string;
readonly confirm_password: string;
}, ParseResult.ArrayFormatterIssue[]>>(this: Either.Either<...>, ab: (_: Either.Either<...>) => Either.Either<...>): Either.Either<...> (+21 overloads)
pipe(28 import Either
Either.const mapLeft: <ParseResult.ParseError, ParseResult.ArrayFormatterIssue[]>(f: (left: ParseResult.ParseError) => ParseResult.ArrayFormatterIssue[]) => <R>(self: Either.Either<...>) => Either.Either<...> (+1 overload)
Maps the `Left` side of an `Either` value to a new `Either` value.
mapLeft(((parameter) error: ParseResult.ParseError
error) =>29 import ParseResult
ParseResult.const ArrayFormatter: ParseResult.ParseResultFormatter<ParseResult.ArrayFormatterIssue[]>
ArrayFormatter.(property) ParseResultFormatter<ArrayFormatterIssue[]>.formatErrorSync: (error: ParseResult.ParseError) => ParseResult.ArrayFormatterIssue[]
formatErrorSync((parameter) error: ParseResult.ParseError
error)30 )31 ),32 null,33 234 )35)36/*37 "_id": "Either",38 "_tag": "Left",39 "left": [40 {41 "_tag": "Type",42 "path": [43 "confirm_password"44 ],45 "message": "Passwords do not match"46 }47 ]48}49*/
In this example, we define a MyForm
schema with two password fields (password
and confirm_password
). We use Schema.filter
to check that both passwords match. If they don’t, an error message is returned, specifically associated with the confirm_password
field. This makes it easier to pinpoint the exact location of the validation failure.
The error is formatted in a structured way using ArrayFormatter
, allowing for easier post-processing and integration with form libraries.
The Schema.filter
API supports reporting multiple validation issues at once, which is especially useful in scenarios like form validation where several checks might fail simultaneously.
Example (Reporting Multiple Validation Errors)
1import { import Either
Either, import Schema
Schema, import ParseResult
ParseResult } from "effect"2
3const const Password: Schema.filter<Schema.Schema<string, string, never>>
Password = import Schema
Schema.class Trim
This schema allows removing whitespaces from the beginning and end of a string.
Trim.(method) Pipeable.pipe<typeof Schema.Trim, Schema.filter<Schema.Schema<string, string, never>>>(this: typeof Schema.Trim, ab: (_: typeof Schema.Trim) => Schema.filter<Schema.Schema<string, string, never>>): Schema.filter<...> (+21 overloads)
pipe(import Schema
Schema.const minLength: <string>(minLength: number, annotations?: Schema.Annotations.Filter<string, string> | undefined) => <I, R>(self: Schema.Schema<string, I, R>) => Schema.filter<...>
minLength(2))4const const OptionalString: Schema.optional<typeof Schema.String>
OptionalString = import Schema
Schema.const optional: <typeof Schema.String>(self: typeof Schema.String) => Schema.optional<typeof Schema.String>
optional(import Schema
Schema.(alias) class String
export String
String)5
6const const MyForm: Schema.filter<Schema.Struct<{
password: Schema.filter<Schema.Schema<string, string, never>>;
confirm_password: Schema.filter<Schema.Schema<string, string, never>>;
name: Schema.optional<...>;
surname: Schema.optional<...>;
}>>
MyForm = import Schema
Schema.function Struct<{
password: Schema.filter<Schema.Schema<string, string, never>>;
confirm_password: Schema.filter<Schema.Schema<string, string, never>>;
name: Schema.optional<...>;
surname: Schema.optional<...>;
}>(fields: {
...;
}): Schema.Struct<...> (+1 overload)
namespace Struct
Struct({7 (property) password: Schema.filter<Schema.Schema<string, string, never>>
password: const Password: Schema.filter<Schema.Schema<string, string, never>>
Password,8 (property) confirm_password: Schema.filter<Schema.Schema<string, string, never>>
confirm_password: const Password: Schema.filter<Schema.Schema<string, string, never>>
Password,9 (property) name: Schema.optional<typeof Schema.String>
name: const OptionalString: Schema.optional<typeof Schema.String>
OptionalString,10 (property) surname: Schema.optional<typeof Schema.String>
surname: const OptionalString: Schema.optional<typeof Schema.String>
OptionalString11}).(method) Pipeable.pipe<Schema.Struct<{
password: Schema.filter<Schema.Schema<string, string, never>>;
confirm_password: Schema.filter<Schema.Schema<string, string, never>>;
name: Schema.optional<...>;
surname: Schema.optional<...>;
}>, Schema.filter<...>>(this: Schema.Struct<...>, ab: (_: Schema.Struct<...>) => Schema.filter<...>): Schema.filter<...> (+21 overloads)
pipe(12 import Schema
Schema.function filter<Schema.Struct<{
password: Schema.filter<Schema.Schema<string, string, never>>;
confirm_password: Schema.filter<Schema.Schema<string, string, never>>;
name: Schema.optional<...>;
surname: Schema.optional<...>;
}>>(predicate: (a: {
...;
}, options: ParseOptions, self: Refinement) => FilterReturnType, annotations?: Schema.Annotations.Filter<...> | undefined): (self: Schema.Struct<...>) => Schema.filter<...> (+2 overloads)
filter(((parameter) input: {
readonly password: string;
readonly confirm_password: string;
readonly name?: string | undefined;
readonly surname?: string | undefined;
}
input) => {13 const const issues: Schema.FilterIssue[]
issues: interface Array<T>
Array<import Schema
Schema.interface FilterIssue
FilterIssue> = []14
15 // Check if passwords match16 if ((parameter) input: {
readonly password: string;
readonly confirm_password: string;
readonly name?: string | undefined;
readonly surname?: string | undefined;
}
input.(property) password: string
password !== (parameter) input: {
readonly password: string;
readonly confirm_password: string;
readonly name?: string | undefined;
readonly surname?: string | undefined;
}
input.(property) confirm_password: string
confirm_password) {17 const issues: Schema.FilterIssue[]
issues.(method) Array<FilterIssue>.push(...items: Schema.FilterIssue[]): number
Appends new elements to the end of an array, and returns the new length of the array.
push({18 (property) FilterIssue.path: readonly PropertyKey[]
path: ["confirm_password"],19 (property) FilterIssue.message: string
message: "Passwords do not match"20 })21 }22
23 // Ensure either name or surname is present24 if (!(parameter) input: {
readonly password: string;
readonly confirm_password: string;
readonly name?: string | undefined;
readonly surname?: string | undefined;
}
input.(property) name?: string | undefined
name && !(parameter) input: {
readonly password: string;
readonly confirm_password: string;
readonly name?: string | undefined;
readonly surname?: string | undefined;
}
input.(property) surname?: string | undefined
surname) {25 const issues: Schema.FilterIssue[]
issues.(method) Array<FilterIssue>.push(...items: Schema.FilterIssue[]): number
Appends new elements to the end of an array, and returns the new length of the array.
push({26 (property) FilterIssue.path: readonly PropertyKey[]
path: ["surname"],27 (property) FilterIssue.message: string
message: "Surname must be present if name is not present"28 })29 }30 return const issues: Schema.FilterIssue[]
issues31 })32)33
34namespace console
var console: Console
The `console` module provides a simple debugging console that is similar to the
JavaScript console mechanism provided by web browsers.
The module exports two specific components:
* A `Console` class with methods such as `console.log()`, `console.error()` and `console.warn()` that can be used to write to any Node.js stream.
* A global `console` instance configured to write to [`process.stdout`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstdout) and
[`process.stderr`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstderr). The global `console` can be used without importing the `node:console` module.
_**Warning**_: The global console object's methods are neither consistently
synchronous like the browser APIs they resemble, nor are they consistently
asynchronous like all other Node.js streams. See the [`note on process I/O`](https://nodejs.org/docs/latest-v22.x/api/process.html#a-note-on-process-io) for
more information.
Example using the global `console`:
```js
console.log('hello world');
// Prints: hello world, to stdout
console.log('hello %s', 'world');
// Prints: hello world, to stdout
console.error(new Error('Whoops, something bad happened'));
// Prints error message and stack trace to stderr:
// Error: Whoops, something bad happened
// at [eval]:5:15
// at Script.runInThisContext (node:vm:132:18)
// at Object.runInThisContext (node:vm:309:38)
// at node:internal/process/execution:77:19
// at [eval]-wrapper:6:22
// at evalScript (node:internal/process/execution:76:60)
// at node:internal/main/eval_string:23:3
const name = 'Will Robinson';
console.warn(`Danger ${name}! Danger!`);
// Prints: Danger Will Robinson! Danger!, to stderr
```
Example using the `Console` class:
```js
const out = getStreamSomehow();
const err = getStreamSomehow();
const myConsole = new console.Console(out, err);
myConsole.log('hello world');
// Prints: hello world, to out
myConsole.log('hello %s', 'world');
// Prints: hello world, to out
myConsole.error(new Error('Whoops, something bad happened'));
// Prints: [Error: Whoops, something bad happened], to err
const name = 'Will Robinson';
myConsole.warn(`Danger ${name}! Danger!`);
// Prints: Danger Will Robinson! Danger!, to err
```
console.(method) Console.log(message?: any, ...optionalParams: any[]): void
Prints to `stdout` with newline. Multiple arguments can be passed, with the
first used as the primary message and all additional used as substitution
values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html)
(the arguments are all passed to [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args)).
```js
const count = 5;
console.log('count: %d', count);
// Prints: count: 5, to stdout
console.log('count:', count);
// Prints: count: 5, to stdout
```
See [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args) for more information.
log(35 var JSON: JSON
An intrinsic object that provides functions to convert JavaScript values to and from the JavaScript Object Notation (JSON) format.
JSON.(method) JSON.stringify(value: any, replacer?: (number | string)[] | null, space?: string | number): string (+1 overload)
Converts a JavaScript value to a JavaScript Object Notation (JSON) string.
stringify(36 import Schema
Schema.const decodeUnknownEither: <{
readonly password: string;
readonly confirm_password: string;
readonly name?: string | undefined;
readonly surname?: string | undefined;
}, {
readonly password: string;
readonly confirm_password: string;
readonly name?: string | undefined;
readonly surname?: string | undefined;
}>(schema: Schema.Schema<...>, options?: ParseOptions) => (u: unknown, overrideOptions?: ParseOptions) => Either.Either<...>
decodeUnknownEither(const MyForm: Schema.filter<Schema.Struct<{
password: Schema.filter<Schema.Schema<string, string, never>>;
confirm_password: Schema.filter<Schema.Schema<string, string, never>>;
name: Schema.optional<...>;
surname: Schema.optional<...>;
}>>
MyForm)({37 (property) password: string
password: "abc",38 (property) confirm_password: string
confirm_password: "d" // Confirm password does not match39 }).(method) Pipeable.pipe<Either.Either<{
readonly password: string;
readonly confirm_password: string;
readonly name?: string | undefined;
readonly surname?: string | undefined;
}, ParseResult.ParseError>, Either.Either<...>>(this: Either.Either<...>, ab: (_: Either.Either<...>) => Either.Either<...>): Either.Either<...> (+21 overloads)
pipe(40 import Either
Either.const mapLeft: <ParseResult.ParseError, ParseResult.ArrayFormatterIssue[]>(f: (left: ParseResult.ParseError) => ParseResult.ArrayFormatterIssue[]) => <R>(self: Either.Either<...>) => Either.Either<...> (+1 overload)
Maps the `Left` side of an `Either` value to a new `Either` value.
mapLeft(((parameter) error: ParseResult.ParseError
error) =>41 import ParseResult
ParseResult.const ArrayFormatter: ParseResult.ParseResultFormatter<ParseResult.ArrayFormatterIssue[]>
ArrayFormatter.(property) ParseResultFormatter<ArrayFormatterIssue[]>.formatErrorSync: (error: ParseResult.ParseError) => ParseResult.ArrayFormatterIssue[]
formatErrorSync((parameter) error: ParseResult.ParseError
error)42 )43 ),44 null,45 246 )47)48/*49{50 "_id": "Either",51 "_tag": "Left",52 "left": [53 {54 "_tag": "Type",55 "path": [56 "confirm_password"57 ],58 "message": "Passwords do not match"59 },60 {61 "_tag": "Type",62 "path": [63 "surname"64 ],65 "message": "Surname must be present if name is not present"66 }67 ]68}69*/
In this example, we define a MyForm
schema with fields for password validation and optional name/surname fields. The Schema.filter
function checks if the passwords match and ensures that either a name or surname is provided. If either validation fails, the corresponding error message is associated with the relevant field and both errors are returned in a structured format.
When working with schemas that have filters, you can access the base schema (the schema before the filter was applied) using the from
property:
1import { import Schema
Schema } from "effect"2
3const const LongString: Schema.filter<typeof Schema.String>
LongString = import Schema
Schema.(alias) class String
export String
String.(method) Pipeable.pipe<typeof Schema.String, Schema.filter<typeof Schema.String>>(this: typeof Schema.String, ab: (_: typeof Schema.String) => Schema.filter<typeof Schema.String>): Schema.filter<...> (+21 overloads)
pipe(4 import Schema
Schema.function filter<typeof Schema.String>(predicate: (a: string, options: ParseOptions, self: Refinement) => FilterReturnType, annotations?: Schema.Annotations.Filter<...> | undefined): (self: typeof Schema.String) => Schema.filter<...> (+2 overloads)
filter(((parameter) s: string
s) => (parameter) s: string
s.(property) String.length: number
Returns the length of a String object.
length >= 10)5)6
7// Access the base schema, which is the string schema8// before the filter was applied9const const From: typeof Schema.String
From = const LongString: Schema.filter<typeof Schema.String>
LongString.(property) refine<string, typeof String$>.from: typeof Schema.String
from10// ^? const From: typeof Schema.String
1import { import Schema
Schema } from "effect"2
3// Specifies maximum length of a string4import Schema
Schema.(alias) class String
export String
String.(method) Pipeable.pipe<typeof Schema.String, Schema.filter<Schema.Schema<string, string, never>>>(this: typeof Schema.String, ab: (_: typeof Schema.String) => Schema.filter<Schema.Schema<string, string, never>>): Schema.filter<...> (+21 overloads)
pipe(import Schema
Schema.const maxLength: <string>(maxLength: number, annotations?: Schema.Annotations.Filter<string, string> | undefined) => <I, R>(self: Schema.Schema<string, I, R>) => Schema.filter<...>
maxLength(5))5
6// Specifies minimum length of a string7import Schema
Schema.(alias) class String
export String
String.(method) Pipeable.pipe<typeof Schema.String, Schema.filter<Schema.Schema<string, string, never>>>(this: typeof Schema.String, ab: (_: typeof Schema.String) => Schema.filter<Schema.Schema<string, string, never>>): Schema.filter<...> (+21 overloads)
pipe(import Schema
Schema.const minLength: <string>(minLength: number, annotations?: Schema.Annotations.Filter<string, string> | undefined) => <I, R>(self: Schema.Schema<string, I, R>) => Schema.filter<...>
minLength(5))8
9// Equivalent to ensuring the string has a minimum length of 110import Schema
Schema.class NonEmptyString
NonEmptyString11
12// Specifies exact length of a string13import Schema
Schema.(alias) class String
export String
String.(method) Pipeable.pipe<typeof Schema.String, Schema.filter<Schema.Schema<string, string, never>>>(this: typeof Schema.String, ab: (_: typeof Schema.String) => Schema.filter<Schema.Schema<string, string, never>>): Schema.filter<...> (+21 overloads)
pipe(import Schema
Schema.const length: <string>(length: number | {
readonly min: number;
readonly max: number;
}, annotations?: Schema.Annotations.Filter<string, string> | undefined) => <I, R>(self: Schema.Schema<...>) => Schema.filter<...>
length(5))14
15// Specifies a range for the length of a string16import Schema
Schema.(alias) class String
export String
String.(method) Pipeable.pipe<typeof Schema.String, Schema.filter<Schema.Schema<string, string, never>>>(this: typeof Schema.String, ab: (_: typeof Schema.String) => Schema.filter<Schema.Schema<string, string, never>>): Schema.filter<...> (+21 overloads)
pipe(import Schema
Schema.const length: <string>(length: number | {
readonly min: number;
readonly max: number;
}, annotations?: Schema.Annotations.Filter<string, string> | undefined) => <I, R>(self: Schema.Schema<...>) => Schema.filter<...>
length({ (property) min: number
min: 2, (property) max: number
max: 4 }))17
18// Matches a string against a regular expression pattern19import Schema
Schema.(alias) class String
export String
String.(method) Pipeable.pipe<typeof Schema.String, Schema.filter<Schema.Schema<string, string, never>>>(this: typeof Schema.String, ab: (_: typeof Schema.String) => Schema.filter<Schema.Schema<string, string, never>>): Schema.filter<...> (+21 overloads)
pipe(import Schema
Schema.const pattern: <string>(regex: RegExp, annotations?: Schema.Annotations.Filter<string, string> | undefined) => <I, R>(self: Schema.Schema<string, I, R>) => Schema.filter<Schema.Schema<...>>
pattern(/^[a-z]+$/))20
21// Ensures a string starts with a specific substring22import Schema
Schema.(alias) class String
export String
String.(method) Pipeable.pipe<typeof Schema.String, Schema.filter<Schema.Schema<string, string, never>>>(this: typeof Schema.String, ab: (_: typeof Schema.String) => Schema.filter<Schema.Schema<string, string, never>>): Schema.filter<...> (+21 overloads)
pipe(import Schema
Schema.const startsWith: <string>(startsWith: string, annotations?: Schema.Annotations.Filter<string, string> | undefined) => <I, R>(self: Schema.Schema<string, I, R>) => Schema.filter<...>
startsWith("prefix"))23
24// Ensures a string ends with a specific substring25import Schema
Schema.(alias) class String
export String
String.(method) Pipeable.pipe<typeof Schema.String, Schema.filter<Schema.Schema<string, string, never>>>(this: typeof Schema.String, ab: (_: typeof Schema.String) => Schema.filter<Schema.Schema<string, string, never>>): Schema.filter<...> (+21 overloads)
pipe(import Schema
Schema.const endsWith: <string>(endsWith: string, annotations?: Schema.Annotations.Filter<string, string> | undefined) => <I, R>(self: Schema.Schema<string, I, R>) => Schema.filter<...>
endsWith("suffix"))26
27// Checks if a string includes a specific substring28import Schema
Schema.(alias) class String
export String
String.(method) Pipeable.pipe<typeof Schema.String, Schema.filter<Schema.Schema<string, string, never>>>(this: typeof Schema.String, ab: (_: typeof Schema.String) => Schema.filter<Schema.Schema<string, string, never>>): Schema.filter<...> (+21 overloads)
pipe(import Schema
Schema.const includes: <string>(searchString: string, annotations?: Schema.Annotations.Filter<string, string> | undefined) => <I, R>(self: Schema.Schema<string, I, R>) => Schema.filter<...>
includes("substring"))29
30// Validates that a string has no leading or trailing whitespaces31import Schema
Schema.(alias) class String
export String
String.(method) Pipeable.pipe<typeof Schema.String, Schema.filter<Schema.Schema<string, string, never>>>(this: typeof Schema.String, ab: (_: typeof Schema.String) => Schema.filter<Schema.Schema<string, string, never>>): Schema.filter<...> (+21 overloads)
pipe(import Schema
Schema.const trimmed: <string>(annotations?: Schema.Annotations.Filter<string, string> | undefined) => <I, R>(self: Schema.Schema<string, I, R>) => Schema.filter<Schema.Schema<string, I, R>>
Verifies that a string contains no leading or trailing whitespaces.
Note. This combinator does not make any transformations, it only validates.
If what you were looking for was a combinator to trim strings, then check out the `trim` combinator.
trimmed())32
33// Validates that a string is entirely in lowercase34import Schema
Schema.(alias) class String
export String
String.(method) Pipeable.pipe<typeof Schema.String, Schema.filter<Schema.Schema<string, string, never>>>(this: typeof Schema.String, ab: (_: typeof Schema.String) => Schema.filter<Schema.Schema<string, string, never>>): Schema.filter<...> (+21 overloads)
pipe(import Schema
Schema.const lowercased: <string>(annotations?: Schema.Annotations.Filter<string, string> | undefined) => <I, R>(self: Schema.Schema<string, I, R>) => Schema.filter<Schema.Schema<string, I, R>>
Verifies that a string is lowercased.
lowercased())35
36// Validates that a string is entirely in uppercase37import Schema
Schema.(alias) class String
export String
String.(method) Pipeable.pipe<typeof Schema.String, Schema.filter<Schema.Schema<string, string, never>>>(this: typeof Schema.String, ab: (_: typeof Schema.String) => Schema.filter<Schema.Schema<string, string, never>>): Schema.filter<...> (+21 overloads)
pipe(import Schema
Schema.const uppercased: <string>(annotations?: Schema.Annotations.Filter<string, string> | undefined) => <I, R>(self: Schema.Schema<string, I, R>) => Schema.filter<Schema.Schema<string, I, R>>
Verifies that a string is uppercased.
uppercased())38
39// Validates that a string is capitalized40import Schema
Schema.(alias) class String
export String
String.(method) Pipeable.pipe<typeof Schema.String, Schema.filter<Schema.Schema<string, string, never>>>(this: typeof Schema.String, ab: (_: typeof Schema.String) => Schema.filter<Schema.Schema<string, string, never>>): Schema.filter<...> (+21 overloads)
pipe(import Schema
Schema.const capitalized: <string>(annotations?: Schema.Annotations.Filter<string, string> | undefined) => <I, R>(self: Schema.Schema<string, I, R>) => Schema.filter<Schema.Schema<string, I, R>>
Verifies that a string is capitalized.
capitalized())41
42// Validates that a string is uncapitalized43import Schema
Schema.(alias) class String
export String
String.(method) Pipeable.pipe<typeof Schema.String, Schema.filter<Schema.Schema<string, string, never>>>(this: typeof Schema.String, ab: (_: typeof Schema.String) => Schema.filter<Schema.Schema<string, string, never>>): Schema.filter<...> (+21 overloads)
pipe(import Schema
Schema.const uncapitalized: <string>(annotations?: Schema.Annotations.Filter<string, string> | undefined) => <I, R>(self: Schema.Schema<string, I, R>) => Schema.filter<Schema.Schema<string, I, R>>
Verifies that a string is uncapitalized.
uncapitalized())
1import { import Schema
Schema } from "effect"2
3// Specifies a number greater than 54import Schema
Schema.(alias) class Number
export Number
Number.(method) Pipeable.pipe<typeof Schema.Number, Schema.filter<Schema.Schema<number, number, never>>>(this: typeof Schema.Number, ab: (_: typeof Schema.Number) => Schema.filter<Schema.Schema<number, number, never>>): Schema.filter<...> (+21 overloads)
pipe(import Schema
Schema.const greaterThan: <number>(min: number, annotations?: Schema.Annotations.Filter<number, number> | undefined) => <I, R>(self: Schema.Schema<number, I, R>) => Schema.filter<Schema.Schema<number, I, R>>
This filter checks whether the provided number is greater than the specified minimum.
greaterThan(5))5
6// Specifies a number greater than or equal to 57import Schema
Schema.(alias) class Number
export Number
Number.(method) Pipeable.pipe<typeof Schema.Number, Schema.filter<Schema.Schema<number, number, never>>>(this: typeof Schema.Number, ab: (_: typeof Schema.Number) => Schema.filter<Schema.Schema<number, number, never>>): Schema.filter<...> (+21 overloads)
pipe(import Schema
Schema.const greaterThanOrEqualTo: <number>(min: number, annotations?: Schema.Annotations.Filter<number, number> | undefined) => <I, R>(self: Schema.Schema<number, I, R>) => Schema.filter<Schema.Schema<number, I, R>>
This filter checks whether the provided number is greater than or equal to the specified minimum.
greaterThanOrEqualTo(5))8
9// Specifies a number less than 510import Schema
Schema.(alias) class Number
export Number
Number.(method) Pipeable.pipe<typeof Schema.Number, Schema.filter<Schema.Schema<number, number, never>>>(this: typeof Schema.Number, ab: (_: typeof Schema.Number) => Schema.filter<Schema.Schema<number, number, never>>): Schema.filter<...> (+21 overloads)
pipe(import Schema
Schema.const lessThan: <number>(max: number, annotations?: Schema.Annotations.Filter<number, number> | undefined) => <I, R>(self: Schema.Schema<number, I, R>) => Schema.filter<Schema.Schema<number, I, R>>
This filter checks whether the provided number is less than the specified maximum.
lessThan(5))11
12// Specifies a number less than or equal to 513import Schema
Schema.(alias) class Number
export Number
Number.(method) Pipeable.pipe<typeof Schema.Number, Schema.filter<Schema.Schema<number, number, never>>>(this: typeof Schema.Number, ab: (_: typeof Schema.Number) => Schema.filter<Schema.Schema<number, number, never>>): Schema.filter<...> (+21 overloads)
pipe(import Schema
Schema.const lessThanOrEqualTo: <number>(max: number, annotations?: Schema.Annotations.Filter<number, number> | undefined) => <I, R>(self: Schema.Schema<number, I, R>) => Schema.filter<Schema.Schema<number, I, R>>
This schema checks whether the provided number is less than or equal to the specified maximum.
lessThanOrEqualTo(5))14
15// Specifies a number between -2 and 2, inclusive16import Schema
Schema.(alias) class Number
export Number
Number.(method) Pipeable.pipe<typeof Schema.Number, Schema.filter<Schema.Schema<number, number, never>>>(this: typeof Schema.Number, ab: (_: typeof Schema.Number) => Schema.filter<Schema.Schema<number, number, never>>): Schema.filter<...> (+21 overloads)
pipe(import Schema
Schema.const between: <number>(min: number, max: number, annotations?: Schema.Annotations.Filter<number, number> | undefined) => <I, R>(self: Schema.Schema<number, I, R>) => Schema.filter<...>
This filter checks whether the provided number falls within the specified minimum and maximum values.
between(-2, 2))17
18// Specifies that the value must be an integer19import Schema
Schema.(alias) class Number
export Number
Number.(method) Pipeable.pipe<typeof Schema.Number, Schema.filter<Schema.Schema<number, number, never>>>(this: typeof Schema.Number, ab: (_: typeof Schema.Number) => Schema.filter<Schema.Schema<number, number, never>>): Schema.filter<...> (+21 overloads)
pipe(import Schema
Schema.const int: <number>(annotations?: Schema.Annotations.Filter<number, number> | undefined) => <I, R>(self: Schema.Schema<number, I, R>) => Schema.filter<Schema.Schema<number, I, R>>
int())20
21// Ensures the value is not NaN22import Schema
Schema.(alias) class Number
export Number
Number.(method) Pipeable.pipe<typeof Schema.Number, Schema.filter<Schema.Schema<number, number, never>>>(this: typeof Schema.Number, ab: (_: typeof Schema.Number) => Schema.filter<Schema.Schema<number, number, never>>): Schema.filter<...> (+21 overloads)
pipe(import Schema
Schema.const nonNaN: <number>(annotations?: Schema.Annotations.Filter<number, number> | undefined) => <I, R>(self: Schema.Schema<number, I, R>) => Schema.filter<Schema.Schema<number, I, R>>
nonNaN())23
24// Ensures the value is finite and not Infinity or -Infinity25import Schema
Schema.(alias) class Number
export Number
Number.(method) Pipeable.pipe<typeof Schema.Number, Schema.filter<Schema.Schema<number, number, never>>>(this: typeof Schema.Number, ab: (_: typeof Schema.Number) => Schema.filter<Schema.Schema<number, number, never>>): Schema.filter<...> (+21 overloads)
pipe(import Schema
Schema.const finite: <number>(annotations?: Schema.Annotations.Filter<number, number> | undefined) => <I, R>(self: Schema.Schema<number, I, R>) => Schema.filter<Schema.Schema<number, I, R>>
Ensures that the provided value is a finite number.
This schema filters out non-finite numeric values, allowing only finite numbers to pass through.
finite())26
27// Specifies a positive number (> 0)28import Schema
Schema.(alias) class Number
export Number
Number.(method) Pipeable.pipe<typeof Schema.Number, Schema.filter<Schema.Schema<number, number, never>>>(this: typeof Schema.Number, ab: (_: typeof Schema.Number) => Schema.filter<Schema.Schema<number, number, never>>): Schema.filter<...> (+21 overloads)
pipe(import Schema
Schema.const positive: <number>(annotations?: Schema.Annotations.Filter<number, number> | undefined) => <I, R>(self: Schema.Schema<number, I, R>) => Schema.filter<Schema.Schema<number, I, R>>
positive())29
30// Specifies a non-negative number (>= 0)31import Schema
Schema.(alias) class Number
export Number
Number.(method) Pipeable.pipe<typeof Schema.Number, Schema.filter<Schema.Schema<number, number, never>>>(this: typeof Schema.Number, ab: (_: typeof Schema.Number) => Schema.filter<Schema.Schema<number, number, never>>): Schema.filter<...> (+21 overloads)
pipe(import Schema
Schema.const nonNegative: <number>(annotations?: Schema.Annotations.Filter<number, number> | undefined) => <I, R>(self: Schema.Schema<number, I, R>) => Schema.filter<Schema.Schema<number, I, R>>
nonNegative())32
33// Specifies a negative number (< 0)34import Schema
Schema.(alias) class Number
export Number
Number.(method) Pipeable.pipe<typeof Schema.Number, Schema.filter<Schema.Schema<number, number, never>>>(this: typeof Schema.Number, ab: (_: typeof Schema.Number) => Schema.filter<Schema.Schema<number, number, never>>): Schema.filter<...> (+21 overloads)
pipe(import Schema
Schema.const negative: <number>(annotations?: Schema.Annotations.Filter<number, number> | undefined) => <I, R>(self: Schema.Schema<number, I, R>) => Schema.filter<Schema.Schema<number, I, R>>
negative())35
36// Specifies a non-positive number (<= 0)37import Schema
Schema.(alias) class Number
export Number
Number.(method) Pipeable.pipe<typeof Schema.Number, Schema.filter<Schema.Schema<number, number, never>>>(this: typeof Schema.Number, ab: (_: typeof Schema.Number) => Schema.filter<Schema.Schema<number, number, never>>): Schema.filter<...> (+21 overloads)
pipe(import Schema
Schema.const nonPositive: <number>(annotations?: Schema.Annotations.Filter<number, number> | undefined) => <I, R>(self: Schema.Schema<number, I, R>) => Schema.filter<Schema.Schema<number, I, R>>
nonPositive())38
39// Specifies a number that is evenly divisible by 540import Schema
Schema.(alias) class Number
export Number
Number.(method) Pipeable.pipe<typeof Schema.Number, Schema.filter<Schema.Schema<number, number, never>>>(this: typeof Schema.Number, ab: (_: typeof Schema.Number) => Schema.filter<Schema.Schema<number, number, never>>): Schema.filter<...> (+21 overloads)
pipe(import Schema
Schema.const multipleOf: <number>(divisor: number, annotations?: Schema.Annotations.Filter<number, number> | undefined) => <I, R>(self: Schema.Schema<number, I, R>) => Schema.filter<...>
multipleOf(5))
1import { import Schema
Schema } from "effect"2
3// Specifies the maximum number of items in the array4import Schema
Schema.(alias) Array<typeof Schema.Number>(value: typeof Schema.Number): Schema.Array$<typeof Schema.Number>
export Array
Array(import Schema
Schema.(alias) class Number
export Number
Number).(method) Pipeable.pipe<Schema.Array$<typeof Schema.Number>, Schema.filter<Schema.Schema<readonly number[], readonly number[], never>>>(this: Schema.Array$<...>, ab: (_: Schema.Array$<typeof Schema.Number>) => Schema.filter<...>): Schema.filter<...> (+21 overloads)
pipe(import Schema
Schema.const maxItems: <number>(n: number, annotations?: Schema.Annotations.Filter<readonly number[], readonly number[]> | undefined) => <I, R>(self: Schema.Schema<readonly number[], I, R>) => Schema.filter<Schema.Schema<readonly number[], I, R>>
maxItems(2))5
6// Specifies the minimum number of items in the array7import Schema
Schema.(alias) Array<typeof Schema.Number>(value: typeof Schema.Number): Schema.Array$<typeof Schema.Number>
export Array
Array(import Schema
Schema.(alias) class Number
export Number
Number).(method) Pipeable.pipe<Schema.Array$<typeof Schema.Number>, Schema.filter<Schema.Schema<readonly number[], readonly number[], never>>>(this: Schema.Array$<...>, ab: (_: Schema.Array$<typeof Schema.Number>) => Schema.filter<...>): Schema.filter<...> (+21 overloads)
pipe(import Schema
Schema.const minItems: <number>(n: number, annotations?: Schema.Annotations.Filter<readonly number[], readonly number[]> | undefined) => <I, R>(self: Schema.Schema<readonly number[], I, R>) => Schema.filter<Schema.Schema<readonly number[], I, R>>
minItems(2))8
9// Specifies the exact number of items in the array10import Schema
Schema.(alias) Array<typeof Schema.Number>(value: typeof Schema.Number): Schema.Array$<typeof Schema.Number>
export Array
Array(import Schema
Schema.(alias) class Number
export Number
Number).(method) Pipeable.pipe<Schema.Array$<typeof Schema.Number>, Schema.filter<Schema.Schema<readonly number[], readonly number[], never>>>(this: Schema.Array$<...>, ab: (_: Schema.Array$<typeof Schema.Number>) => Schema.filter<...>): Schema.filter<...> (+21 overloads)
pipe(import Schema
Schema.const itemsCount: <number>(n: number, annotations?: Schema.Annotations.Filter<readonly number[], readonly number[]> | undefined) => <I, R>(self: Schema.Schema<readonly number[], I, R>) => Schema.filter<Schema.Schema<readonly number[], I, R>>
itemsCount(2))
1import { import Schema
Schema } from "effect"2
3// Specifies a BigInt greater than 54import Schema
Schema.(alias) class BigInt
export BigInt
This schema transforms a `string` into a `bigint` by parsing the string using the `BigInt` function.
It returns an error if the value can't be converted (for example when non-numeric characters are provided).
BigInt.(method) Pipeable.pipe<typeof Schema.BigInt, Schema.filter<Schema.Schema<bigint, string, never>>>(this: typeof Schema.BigInt, ab: (_: typeof Schema.BigInt) => Schema.filter<Schema.Schema<bigint, string, never>>): Schema.filter<...> (+21 overloads)
pipe(import Schema
Schema.const greaterThanBigInt: <bigint>(min: bigint, annotations?: Schema.Annotations.Filter<bigint, bigint> | undefined) => <I, R>(self: Schema.Schema<bigint, I, R>) => Schema.filter<Schema.Schema<bigint, I, R>>
greaterThanBigInt(5n))5
6// Specifies a BigInt greater than or equal to 57import Schema
Schema.(alias) class BigInt
export BigInt
This schema transforms a `string` into a `bigint` by parsing the string using the `BigInt` function.
It returns an error if the value can't be converted (for example when non-numeric characters are provided).
BigInt.(method) Pipeable.pipe<typeof Schema.BigInt, Schema.filter<Schema.Schema<bigint, string, never>>>(this: typeof Schema.BigInt, ab: (_: typeof Schema.BigInt) => Schema.filter<Schema.Schema<bigint, string, never>>): Schema.filter<...> (+21 overloads)
pipe(import Schema
Schema.const greaterThanOrEqualToBigInt: <bigint>(min: bigint, annotations?: Schema.Annotations.Filter<bigint, bigint> | undefined) => <I, R>(self: Schema.Schema<bigint, I, R>) => Schema.filter<Schema.Schema<bigint, I, R>>
greaterThanOrEqualToBigInt(5n))8
9// Specifies a BigInt less than 510import Schema
Schema.(alias) class BigInt
export BigInt
This schema transforms a `string` into a `bigint` by parsing the string using the `BigInt` function.
It returns an error if the value can't be converted (for example when non-numeric characters are provided).
BigInt.(method) Pipeable.pipe<typeof Schema.BigInt, Schema.filter<Schema.Schema<bigint, string, never>>>(this: typeof Schema.BigInt, ab: (_: typeof Schema.BigInt) => Schema.filter<Schema.Schema<bigint, string, never>>): Schema.filter<...> (+21 overloads)
pipe(import Schema
Schema.const lessThanBigInt: <bigint>(max: bigint, annotations?: Schema.Annotations.Filter<bigint, bigint> | undefined) => <I, R>(self: Schema.Schema<bigint, I, R>) => Schema.filter<Schema.Schema<bigint, I, R>>
lessThanBigInt(5n))11
12// Specifies a BigInt less than or equal to 513import Schema
Schema.(alias) class BigInt
export BigInt
This schema transforms a `string` into a `bigint` by parsing the string using the `BigInt` function.
It returns an error if the value can't be converted (for example when non-numeric characters are provided).
BigInt.(method) Pipeable.pipe<typeof Schema.BigInt, Schema.filter<Schema.Schema<bigint, string, never>>>(this: typeof Schema.BigInt, ab: (_: typeof Schema.BigInt) => Schema.filter<Schema.Schema<bigint, string, never>>): Schema.filter<...> (+21 overloads)
pipe(import Schema
Schema.const lessThanOrEqualToBigInt: <bigint>(max: bigint, annotations?: Schema.Annotations.Filter<bigint, bigint> | undefined) => <I, R>(self: Schema.Schema<bigint, I, R>) => Schema.filter<Schema.Schema<bigint, I, R>>
lessThanOrEqualToBigInt(5n))14
15// Specifies a BigInt between -2n and 2n, inclusive16import Schema
Schema.(alias) class BigInt
export BigInt
This schema transforms a `string` into a `bigint` by parsing the string using the `BigInt` function.
It returns an error if the value can't be converted (for example when non-numeric characters are provided).
BigInt.(method) Pipeable.pipe<typeof Schema.BigInt, Schema.filter<Schema.Schema<bigint, string, never>>>(this: typeof Schema.BigInt, ab: (_: typeof Schema.BigInt) => Schema.filter<Schema.Schema<bigint, string, never>>): Schema.filter<...> (+21 overloads)
pipe(import Schema
Schema.const betweenBigInt: <bigint>(min: bigint, max: bigint, annotations?: Schema.Annotations.Filter<bigint, bigint> | undefined) => <I, R>(self: Schema.Schema<bigint, I, R>) => Schema.filter<...>
betweenBigInt(-2n, 2n))17
18// Specifies a positive BigInt (> 0n)19import Schema
Schema.(alias) class BigInt
export BigInt
This schema transforms a `string` into a `bigint` by parsing the string using the `BigInt` function.
It returns an error if the value can't be converted (for example when non-numeric characters are provided).
BigInt.(method) Pipeable.pipe<typeof Schema.BigInt, Schema.filter<Schema.Schema<bigint, string, never>>>(this: typeof Schema.BigInt, ab: (_: typeof Schema.BigInt) => Schema.filter<Schema.Schema<bigint, string, never>>): Schema.filter<...> (+21 overloads)
pipe(import Schema
Schema.const positiveBigInt: <bigint>(annotations?: Schema.Annotations.Filter<bigint, bigint> | undefined) => <I, R>(self: Schema.Schema<bigint, I, R>) => Schema.filter<Schema.Schema<bigint, I, R>>
positiveBigInt())20
21// Specifies a non-negative BigInt (>= 0n)22import Schema
Schema.(alias) class BigInt
export BigInt
This schema transforms a `string` into a `bigint` by parsing the string using the `BigInt` function.
It returns an error if the value can't be converted (for example when non-numeric characters are provided).
BigInt.(method) Pipeable.pipe<typeof Schema.BigInt, Schema.filter<Schema.Schema<bigint, string, never>>>(this: typeof Schema.BigInt, ab: (_: typeof Schema.BigInt) => Schema.filter<Schema.Schema<bigint, string, never>>): Schema.filter<...> (+21 overloads)
pipe(import Schema
Schema.const nonNegativeBigInt: <bigint>(annotations?: Schema.Annotations.Filter<bigint, bigint> | undefined) => <I, R>(self: Schema.Schema<bigint, I, R>) => Schema.filter<Schema.Schema<bigint, I, R>>
nonNegativeBigInt())23
24// Specifies a negative BigInt (< 0n)25import Schema
Schema.(alias) class BigInt
export BigInt
This schema transforms a `string` into a `bigint` by parsing the string using the `BigInt` function.
It returns an error if the value can't be converted (for example when non-numeric characters are provided).
BigInt.(method) Pipeable.pipe<typeof Schema.BigInt, Schema.filter<Schema.Schema<bigint, string, never>>>(this: typeof Schema.BigInt, ab: (_: typeof Schema.BigInt) => Schema.filter<Schema.Schema<bigint, string, never>>): Schema.filter<...> (+21 overloads)
pipe(import Schema
Schema.const negativeBigInt: <bigint>(annotations?: Schema.Annotations.Filter<bigint, bigint> | undefined) => <I, R>(self: Schema.Schema<bigint, I, R>) => Schema.filter<Schema.Schema<bigint, I, R>>
negativeBigInt())26
27// Specifies a non-positive BigInt (<= 0n)28import Schema
Schema.(alias) class BigInt
export BigInt
This schema transforms a `string` into a `bigint` by parsing the string using the `BigInt` function.
It returns an error if the value can't be converted (for example when non-numeric characters are provided).
BigInt.(method) Pipeable.pipe<typeof Schema.BigInt, Schema.filter<Schema.Schema<bigint, string, never>>>(this: typeof Schema.BigInt, ab: (_: typeof Schema.BigInt) => Schema.filter<Schema.Schema<bigint, string, never>>): Schema.filter<...> (+21 overloads)
pipe(import Schema
Schema.const nonPositiveBigInt: <bigint>(annotations?: Schema.Annotations.Filter<bigint, bigint> | undefined) => <I, R>(self: Schema.Schema<bigint, I, R>) => Schema.filter<Schema.Schema<bigint, I, R>>
nonPositiveBigInt())
1import { import Schema
Schema } from "effect"2import { import BigDecimal
BigDecimal } from "effect"3
4// Specifies a BigDecimal greater than 55import Schema
Schema.class BigDecimal
BigDecimal.(method) Pipeable.pipe<typeof Schema.BigDecimal, Schema.filter<Schema.Schema<BigDecimal.BigDecimal, string, never>>>(this: typeof Schema.BigDecimal, ab: (_: typeof Schema.BigDecimal) => Schema.filter<Schema.Schema<BigDecimal.BigDecimal, string, never>>): Schema.filter<...> (+21 overloads)
pipe(6 import Schema
Schema.const greaterThanBigDecimal: <BigDecimal.BigDecimal>(min: BigDecimal.BigDecimal, annotations?: Schema.Annotations.Filter<BigDecimal.BigDecimal, BigDecimal.BigDecimal> | undefined) => <I, R>(self: Schema.Schema<...>) => Schema.filter<...>
greaterThanBigDecimal(import BigDecimal
BigDecimal.const fromNumber: (n: number) => BigDecimal.BigDecimal
Creates a `BigDecimal` from a `number` value.
It is not recommended to convert a floating point number to a decimal directly,
as the floating point representation may be unexpected.
fromNumber(5))7)8
9// Specifies a BigDecimal greater than or equal to 510import Schema
Schema.class BigDecimal
BigDecimal.(method) Pipeable.pipe<typeof Schema.BigDecimal, Schema.filter<Schema.Schema<BigDecimal.BigDecimal, string, never>>>(this: typeof Schema.BigDecimal, ab: (_: typeof Schema.BigDecimal) => Schema.filter<Schema.Schema<BigDecimal.BigDecimal, string, never>>): Schema.filter<...> (+21 overloads)
pipe(11 import Schema
Schema.const greaterThanOrEqualToBigDecimal: <BigDecimal.BigDecimal>(min: BigDecimal.BigDecimal, annotations?: Schema.Annotations.Filter<BigDecimal.BigDecimal, BigDecimal.BigDecimal> | undefined) => <I, R>(self: Schema.Schema<...>) => Schema.filter<...>
greaterThanOrEqualToBigDecimal(import BigDecimal
BigDecimal.const fromNumber: (n: number) => BigDecimal.BigDecimal
Creates a `BigDecimal` from a `number` value.
It is not recommended to convert a floating point number to a decimal directly,
as the floating point representation may be unexpected.
fromNumber(5))12)13// Specifies a BigDecimal less than 514import Schema
Schema.class BigDecimal
BigDecimal.(method) Pipeable.pipe<typeof Schema.BigDecimal, Schema.filter<Schema.Schema<BigDecimal.BigDecimal, string, never>>>(this: typeof Schema.BigDecimal, ab: (_: typeof Schema.BigDecimal) => Schema.filter<Schema.Schema<BigDecimal.BigDecimal, string, never>>): Schema.filter<...> (+21 overloads)
pipe(15 import Schema
Schema.const lessThanBigDecimal: <BigDecimal.BigDecimal>(max: BigDecimal.BigDecimal, annotations?: Schema.Annotations.Filter<BigDecimal.BigDecimal, BigDecimal.BigDecimal> | undefined) => <I, R>(self: Schema.Schema<...>) => Schema.filter<...>
lessThanBigDecimal(import BigDecimal
BigDecimal.const fromNumber: (n: number) => BigDecimal.BigDecimal
Creates a `BigDecimal` from a `number` value.
It is not recommended to convert a floating point number to a decimal directly,
as the floating point representation may be unexpected.
fromNumber(5))16)17
18// Specifies a BigDecimal less than or equal to 519import Schema
Schema.class BigDecimal
BigDecimal.(method) Pipeable.pipe<typeof Schema.BigDecimal, Schema.filter<Schema.Schema<BigDecimal.BigDecimal, string, never>>>(this: typeof Schema.BigDecimal, ab: (_: typeof Schema.BigDecimal) => Schema.filter<Schema.Schema<BigDecimal.BigDecimal, string, never>>): Schema.filter<...> (+21 overloads)
pipe(20 import Schema
Schema.const lessThanOrEqualToBigDecimal: <BigDecimal.BigDecimal>(max: BigDecimal.BigDecimal, annotations?: Schema.Annotations.Filter<BigDecimal.BigDecimal, BigDecimal.BigDecimal> | undefined) => <I, R>(self: Schema.Schema<...>) => Schema.filter<...>
lessThanOrEqualToBigDecimal(import BigDecimal
BigDecimal.const fromNumber: (n: number) => BigDecimal.BigDecimal
Creates a `BigDecimal` from a `number` value.
It is not recommended to convert a floating point number to a decimal directly,
as the floating point representation may be unexpected.
fromNumber(5))21)22
23// Specifies a BigDecimal between -2 and 2, inclusive24import Schema
Schema.class BigDecimal
BigDecimal.(method) Pipeable.pipe<typeof Schema.BigDecimal, Schema.filter<Schema.Schema<BigDecimal.BigDecimal, string, never>>>(this: typeof Schema.BigDecimal, ab: (_: typeof Schema.BigDecimal) => Schema.filter<Schema.Schema<BigDecimal.BigDecimal, string, never>>): Schema.filter<...> (+21 overloads)
pipe(25 import Schema
Schema.const betweenBigDecimal: <BigDecimal.BigDecimal>(minimum: BigDecimal.BigDecimal, maximum: BigDecimal.BigDecimal, annotations?: Schema.Annotations.Filter<...> | undefined) => <I, R>(self: Schema.Schema<...>) => Schema.filter<...>
betweenBigDecimal(26 import BigDecimal
BigDecimal.const fromNumber: (n: number) => BigDecimal.BigDecimal
Creates a `BigDecimal` from a `number` value.
It is not recommended to convert a floating point number to a decimal directly,
as the floating point representation may be unexpected.
fromNumber(-2),27 import BigDecimal
BigDecimal.const fromNumber: (n: number) => BigDecimal.BigDecimal
Creates a `BigDecimal` from a `number` value.
It is not recommended to convert a floating point number to a decimal directly,
as the floating point representation may be unexpected.
fromNumber(2)28 )29)30
31// Specifies a positive BigDecimal (> 0)32import Schema
Schema.class BigDecimal
BigDecimal.(method) Pipeable.pipe<typeof Schema.BigDecimal, Schema.filter<Schema.Schema<BigDecimal.BigDecimal, string, never>>>(this: typeof Schema.BigDecimal, ab: (_: typeof Schema.BigDecimal) => Schema.filter<Schema.Schema<BigDecimal.BigDecimal, string, never>>): Schema.filter<...> (+21 overloads)
pipe(import Schema
Schema.const positiveBigDecimal: <BigDecimal.BigDecimal>(annotations?: Schema.Annotations.Filter<BigDecimal.BigDecimal, BigDecimal.BigDecimal> | undefined) => <I, R>(self: Schema.Schema<...>) => Schema.filter<...>
positiveBigDecimal())33
34// Specifies a non-negative BigDecimal (>= 0)35import Schema
Schema.class BigDecimal
BigDecimal.(method) Pipeable.pipe<typeof Schema.BigDecimal, Schema.filter<Schema.Schema<BigDecimal.BigDecimal, string, never>>>(this: typeof Schema.BigDecimal, ab: (_: typeof Schema.BigDecimal) => Schema.filter<Schema.Schema<BigDecimal.BigDecimal, string, never>>): Schema.filter<...> (+21 overloads)
pipe(import Schema
Schema.const nonNegativeBigDecimal: <BigDecimal.BigDecimal>(annotations?: Schema.Annotations.Filter<BigDecimal.BigDecimal, BigDecimal.BigDecimal> | undefined) => <I, R>(self: Schema.Schema<...>) => Schema.filter<...>
nonNegativeBigDecimal())36
37// Specifies a negative BigDecimal (< 0)38import Schema
Schema.class BigDecimal
BigDecimal.(method) Pipeable.pipe<typeof Schema.BigDecimal, Schema.filter<Schema.Schema<BigDecimal.BigDecimal, string, never>>>(this: typeof Schema.BigDecimal, ab: (_: typeof Schema.BigDecimal) => Schema.filter<Schema.Schema<BigDecimal.BigDecimal, string, never>>): Schema.filter<...> (+21 overloads)
pipe(import Schema
Schema.const negativeBigDecimal: <BigDecimal.BigDecimal>(annotations?: Schema.Annotations.Filter<BigDecimal.BigDecimal, BigDecimal.BigDecimal> | undefined) => <I, R>(self: Schema.Schema<...>) => Schema.filter<...>
negativeBigDecimal())39
40// Specifies a non-positive BigDecimal (<= 0)41import Schema
Schema.class BigDecimal
BigDecimal.(method) Pipeable.pipe<typeof Schema.BigDecimal, Schema.filter<Schema.Schema<BigDecimal.BigDecimal, string, never>>>(this: typeof Schema.BigDecimal, ab: (_: typeof Schema.BigDecimal) => Schema.filter<Schema.Schema<BigDecimal.BigDecimal, string, never>>): Schema.filter<...> (+21 overloads)
pipe(import Schema
Schema.const nonPositiveBigDecimal: <BigDecimal.BigDecimal>(annotations?: Schema.Annotations.Filter<BigDecimal.BigDecimal, BigDecimal.BigDecimal> | undefined) => <I, R>(self: Schema.Schema<...>) => Schema.filter<...>
nonPositiveBigDecimal())
1import { import Schema
Schema } from "effect"2
3// Specifies a duration greater than 5 seconds4import Schema
Schema.class Duration
A schema that transforms a `[number, number]` tuple into a `Duration`.
Duration.(method) Pipeable.pipe<typeof Schema.Duration, Schema.filter<Schema.Schema<Duration, readonly [seconds: number, nanos: number], never>>>(this: typeof Schema.Duration, ab: (_: typeof Schema.Duration) => Schema.filter<Schema.Schema<Duration, readonly [seconds: ...], never>>): Schema.filter<...> (+21 overloads)
pipe(import Schema
Schema.const greaterThanDuration: <Duration>(min: DurationInput, annotations?: Schema.Annotations.Filter<Duration, Duration> | undefined) => <I, R>(self: Schema.Schema<...>) => Schema.filter<...>
greaterThanDuration("5 seconds"))5
6// Specifies a duration greater than or equal to 5 seconds7import Schema
Schema.class Duration
A schema that transforms a `[number, number]` tuple into a `Duration`.
Duration.(method) Pipeable.pipe<typeof Schema.Duration, Schema.filter<Schema.Schema<Duration, readonly [seconds: number, nanos: number], never>>>(this: typeof Schema.Duration, ab: (_: typeof Schema.Duration) => Schema.filter<Schema.Schema<Duration, readonly [seconds: ...], never>>): Schema.filter<...> (+21 overloads)
pipe(import Schema
Schema.const greaterThanOrEqualToDuration: <Duration>(min: DurationInput, annotations?: Schema.Annotations.Filter<Duration, Duration> | undefined) => <I, R>(self: Schema.Schema<...>) => Schema.filter<...>
greaterThanOrEqualToDuration("5 seconds"))8
9// Specifies a duration less than 5 seconds10import Schema
Schema.class Duration
A schema that transforms a `[number, number]` tuple into a `Duration`.
Duration.(method) Pipeable.pipe<typeof Schema.Duration, Schema.filter<Schema.Schema<Duration, readonly [seconds: number, nanos: number], never>>>(this: typeof Schema.Duration, ab: (_: typeof Schema.Duration) => Schema.filter<Schema.Schema<Duration, readonly [seconds: ...], never>>): Schema.filter<...> (+21 overloads)
pipe(import Schema
Schema.const lessThanDuration: <Duration>(max: DurationInput, annotations?: Schema.Annotations.Filter<Duration, Duration> | undefined) => <I, R>(self: Schema.Schema<...>) => Schema.filter<...>
lessThanDuration("5 seconds"))11
12// Specifies a duration less than or equal to 5 seconds13import Schema
Schema.class Duration
A schema that transforms a `[number, number]` tuple into a `Duration`.
Duration.(method) Pipeable.pipe<typeof Schema.Duration, Schema.filter<Schema.Schema<Duration, readonly [seconds: number, nanos: number], never>>>(this: typeof Schema.Duration, ab: (_: typeof Schema.Duration) => Schema.filter<Schema.Schema<Duration, readonly [seconds: ...], never>>): Schema.filter<...> (+21 overloads)
pipe(import Schema
Schema.const lessThanOrEqualToDuration: <Duration>(max: DurationInput, annotations?: Schema.Annotations.Filter<Duration, Duration> | undefined) => <I, R>(self: Schema.Schema<...>) => Schema.filter<...>
lessThanOrEqualToDuration("5 seconds"))14
15// Specifies a duration between 5 seconds and 10 seconds, inclusive16import Schema
Schema.class Duration
A schema that transforms a `[number, number]` tuple into a `Duration`.
Duration.(method) Pipeable.pipe<typeof Schema.Duration, Schema.filter<Schema.Schema<Duration, readonly [seconds: number, nanos: number], never>>>(this: typeof Schema.Duration, ab: (_: typeof Schema.Duration) => Schema.filter<Schema.Schema<Duration, readonly [seconds: ...], never>>): Schema.filter<...> (+21 overloads)
pipe(import Schema
Schema.const betweenDuration: <Duration>(minimum: DurationInput, maximum: DurationInput, annotations?: Schema.Annotations.Filter<Duration, Duration> | undefined) => <I, R>(self: Schema.Schema<...>) => Schema.filter<...>
betweenDuration("5 seconds", "10 seconds"))