Skip to content

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 (Defining a Minimum String Length Filter)

1
import {
import Schema
Schema
} from "effect"
2
3
// Define a string schema with a filter to ensure the string
4
// is at least 10 characters long
5
const
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 characters
8
(
(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
// ┌─── string
13
// ▼
14
type
type Type = string
Type
= typeof
const LongString: Schema.filter<typeof Schema.String>
LongString
.
(property) Schema<string, string, never>.Type: string
Type
15
16
namespace 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"))
17
/*
18
throws:
19
ParseError: { string | filter }
20
└─ Predicate refinement failure
21
└─ a string at least 10 characters long
22
*/

Note that the filter does not alter the schema’s Type:

// ┌─── string
// ▼
type Type = typeof LongString.Type

Filters add additional validation constraints without modifying the schema’s underlying type.

The predicate function in a filter follows this structure:

1
type Predicate = (
2
a: A,
3
options: ParseOptions,
4
self: AST.Refinement
5
) => FilterReturnType

where

1
interface FilterIssue {
2
readonly path: ReadonlyArray<PropertyKey>
3
readonly issue: string | ParseResult.ParseIssue
4
}
5
6
type FilterOutput =
7
| undefined
8
| boolean
9
| string
10
| ParseResult.ParseIssue
11
| FilterIssue
12
13
type FilterReturnType = FilterOutput | ReadonlyArray<FilterOutput>

The filter’s predicate can return several types of values, each affecting validation in a different way:

Return TypeBehavior
trueThe data satisfies the filter’s condition and passes validation.
false or undefinedThe data does not meet the condition, and no specific error message is provided.
stringThe validation fails, and the provided string is used as the error message.
ParseResult.ParseIssueThe validation fails with a detailed error structure, specifying where and why it failed.
FilterIssueAllows 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.

Embedding metadata within the schema, such as identifiers, JSON schema specifications, and descriptions, enhances understanding and analysis of the schema’s constraints and purpose.

Example (Adding Metadata with Annotations)

1
import {
import Schema
Schema
,
import JSONSchema
JSONSchema
} from "effect"
2
3
const
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
15
namespace 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
/*
17
throws:
18
ParseError: LongString
19
└─ Predicate refinement failure
20
└─ a string at least 10 characters long
21
*/
22
23
namespace 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
/*
25
Output:
26
{
27
'$schema': 'http://json-schema.org/draft-07/schema#',
28
type: 'string',
29
description: 'Lorem ipsum dolor sit amet, ...',
30
minLength: 10
31
}
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 (Matching Passwords)

1
import {
import Either
Either
,
import Schema
Schema
,
import ParseResult
ParseResult
} from "effect"
2
3
const
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
5
const
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>>
Password
8
}).
(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 match
10
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 associated
13
// with the "confirm_password" field
14
return {
15
(property) path: [string]
path
: ["confirm_password"],
16
(property) message: string
message
: "Passwords do not match"
17
}
18
}
19
})
20
)
21
22
namespace 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 match
27
}).
(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
2
34
)
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)

1
import {
import Either
Either
,
import Schema
Schema
,
import ParseResult
ParseResult
} from "effect"
2
3
const
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
const
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
6
const
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>
OptionalString
11
}).
(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 match
16
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 present
24
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[]
issues
31
})
32
)
33
34
namespace 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 match
39
}).
(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
2
46
)
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.

For schemas with filters, you can access the base schema (the schema before the filter was applied) using the from property:

1
import {
import Schema
Schema
} from "effect"
2
3
const
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 schema
8
// before the filter was applied
9
//
10
// ┌─── typeof Schema.String
11
// ▼
12
const
const From: typeof Schema.String
From
=
const LongString: Schema.filter<typeof Schema.String>
LongString
.
(property) refine<string, typeof String$>.from: typeof Schema.String
from

Here is a list of useful string filters provided by the Schema module:

1
import {
import Schema
Schema
} from "effect"
2
3
// Specifies maximum length of a string
4
import 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 string
7
import 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 1
10
import Schema
Schema
.
class NonEmptyString
NonEmptyString
11
12
// Specifies exact length of a string
13
import 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 string
16
import 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 pattern
19
import 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 substring
22
import 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 substring
25
import 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 substring
28
import 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 whitespaces
31
import 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 lowercase
34
import 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 uppercase
37
import 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 capitalized
40
import 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 uncapitalized
43
import 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
())

Here is a list of useful number filters provided by the Schema module:

1
import {
import Schema
Schema
} from "effect"
2
3
// Specifies a number greater than 5
4
import 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 5
7
import 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 5
10
import 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 5
13
import 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, inclusive
16
import 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 integer
19
import 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 NaN
22
import 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 -Infinity
25
import 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)
28
import 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)
31
import 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)
34
import 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)
37
import 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 5
40
import 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))

Here is a list of useful array filters provided by the Schema module:

1
import {
import Schema
Schema
} from "effect"
2
3
// Specifies the maximum number of items in the array
4
import 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 array
7
import 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 array
10
import 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))

Here is a list of useful BigInt filters provided by the Schema module:

1
import {
import Schema
Schema
} from "effect"
2
3
// Specifies a BigInt greater than 5
4
import 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 5
7
import 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 5
10
import 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 5
13
import 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, inclusive
16
import 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)
19
import 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)
22
import 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)
25
import 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)
28
import 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
())

Here is a list of useful BigDecimal filters provided by the Schema module:

1
import {
import Schema
Schema
} from "effect"
2
import {
import BigDecimal
BigDecimal
} from "effect"
3
4
// Specifies a BigDecimal greater than 5
5
import 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 5
10
import 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 5
14
import 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 5
19
import 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, inclusive
24
import 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)
32
import 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)
35
import 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)
38
import 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)
41
import 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
())

Here is a list of useful Duration filters provided by the Schema module:

1
import {
import Schema
Schema
} from "effect"
2
3
// Specifies a duration greater than 5 seconds
4
import 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 seconds
7
import 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 seconds
10
import 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 seconds
13
import 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, inclusive
16
import 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"))