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)

import {
import Schema
Schema
} from "effect"
// Define a string schema with a filter to ensure the string
// is at least 10 characters long
const
const LongString: Schema.filter<typeof Schema.String>
LongString
=
import Schema
Schema
.
class String
export String

@since3.10.0

String
.
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
(
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)

@since3.10.0

filter
(
// Custom error message for strings shorter than 10 characters
(
s: string
s
) =>
s: string
s
.
String.length: number

Returns the length of a String object.

length
>= 10 || "a string at least 10 characters long"
)
)
// ┌─── string
// ▼
type
type Type = string
Type
= typeof
const LongString: Schema.filter<typeof Schema.String>
LongString
.
Schema<string, string, never>.Type: string
Type
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 and process.stderr. 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 for more information.

Example using the global console:

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:

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

@seesource

console
.
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) (the arguments are all passed to util.format()).

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() for more information.

@sincev0.1.100

log
(
import Schema
Schema
.
decodeUnknownSync<string, string>(schema: Schema.Schema<string, string, never>, options?: ParseOptions): (u: unknown, overrideOptions?: ParseOptions) => string
export decodeUnknownSync

@throwsParseError

@since3.10.0

decodeUnknownSync
(
const LongString: Schema.filter<typeof Schema.String>
LongString
)("a"))
/*
throws:
ParseError: { string | filter }
└─ Predicate refinement failure
└─ a string at least 10 characters long
*/

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:

type Predicate = (
a: A,
options: ParseOptions,
self: AST.Refinement
) => FilterReturnType

where

interface FilterIssue {
readonly path: ReadonlyArray<PropertyKey>
readonly issue: string | ParseResult.ParseIssue
}
type FilterOutput =
| undefined
| boolean
| string
| ParseResult.ParseIssue
| FilterIssue
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)

import {
import Schema
Schema
,
import JSONSchema
JSONSchema
} from "effect"
const
const LongString: Schema.filter<typeof Schema.String>
LongString
=
import Schema
Schema
.
class String
export String

@since3.10.0

String
.
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
(
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)

@since3.10.0

filter
(
(
s: string
s
) =>
s: string
s
.
String.length: number

Returns the length of a String object.

length
>= 10 ?
var undefined
undefined
: "a string at least 10 characters long",
{
Annotations.Schema<A, TypeParameters extends ReadonlyArray<any> = readonly []>.identifier?: string
identifier
: "LongString",
Annotations.Schema<A, TypeParameters extends ReadonlyArray<any> = readonly []>.jsonSchema?: object
jsonSchema
: {
minLength: number
minLength
: 10 },
Annotations.Doc<A>.description?: string
description
: "Lorem ipsum dolor sit amet, ..."
}
)
)
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 and process.stderr. 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 for more information.

Example using the global console:

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:

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

@seesource

console
.
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) (the arguments are all passed to util.format()).

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() for more information.

@sincev0.1.100

log
(
import Schema
Schema
.
decodeUnknownSync<string, string>(schema: Schema.Schema<string, string, never>, options?: ParseOptions): (u: unknown, overrideOptions?: ParseOptions) => string
export decodeUnknownSync

@throwsParseError

@since3.10.0

decodeUnknownSync
(
const LongString: Schema.filter<typeof Schema.String>
LongString
)("a"))
/*
throws:
ParseError: LongString
└─ Predicate refinement failure
└─ a string at least 10 characters long
*/
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 and process.stderr. 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 for more information.

Example using the global console:

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:

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

@seesource

console
.
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) (the arguments are all passed to util.format()).

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() for more information.

@sincev0.1.100

log
(
import JSONSchema
JSONSchema
.
const make: <string, string, never>(schema: Schema.Schema<string, string, never>) => JSONSchema.JsonSchema7Root

@since3.10.0

make
(
const LongString: Schema.filter<typeof Schema.String>
LongString
))
/*
Output:
{
'$schema': 'http://json-schema.org/draft-07/schema#',
type: 'string',
description: 'Lorem ipsum dolor sit amet, ...',
minLength: 10
}
*/

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)

import {
import Either

@since2.0.0

@since2.0.0

Either
,
import Schema
Schema
,
import ParseResult
ParseResult
} from "effect"
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.

@since3.10.0

Trim
.
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<...>

@since3.10.0

minLength
(2))
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: {
password: Schema.filter<Schema.Schema<string, string, never>>;
confirm_password: Schema.filter<Schema.Schema<string, string, never>>;
}): Schema.Struct<...> (+1 overload)

@since3.10.0

Struct
({
password: Schema.filter<Schema.Schema<string, string, never>>
password
:
const Password: Schema.filter<Schema.Schema<string, string, never>>
Password
,
confirm_password: Schema.filter<Schema.Schema<string, string, never>>
confirm_password
:
const Password: Schema.filter<Schema.Schema<string, string, never>>
Password
}).
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
(
// Add a filter to ensure that passwords match
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)

@since3.10.0

filter
((
input: {
readonly password: string;
readonly confirm_password: string;
}
input
) => {
if (
input: {
readonly password: string;
readonly confirm_password: string;
}
input
.
password: string
password
!==
input: {
readonly password: string;
readonly confirm_password: string;
}
input
.
confirm_password: string
confirm_password
) {
// Return an error message associated
// with the "confirm_password" field
return {
path: [string]
path
: ["confirm_password"],
message: string
message
: "Passwords do not match"
}
}
})
)
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 and process.stderr. 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 for more information.

Example using the global console:

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:

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

@seesource

console
.
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) (the arguments are all passed to util.format()).

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() for more information.

@sincev0.1.100

log
(
var JSON: JSON

An intrinsic object that provides functions to convert JavaScript values to and from the JavaScript Object Notation (JSON) format.

JSON
.
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.

@paramvalue A JavaScript value, usually an object or array, to be converted.

@paramreplacer An array of strings and numbers that acts as an approved list for selecting the object properties that will be stringified.

@paramspace Adds indentation, white space, and line break characters to the return-value JSON text to make it easier to read.

stringify
(
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;
}, {
readonly password: string;
readonly confirm_password: string;
}, never>, options?: ParseOptions) => (u: unknown, overrideOptions?: ParseOptions) => Either.Either<...>

@since3.10.0

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
)({
password: string
password
: "abc",
confirm_password: string
confirm_password
: "d" // Confirm password does not match
}).
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
(
import Either

@since2.0.0

@since2.0.0

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.

@paramself - The input Either value to map.

@paramf - A transformation function to apply to the Left value of the input Either.

@since2.0.0

mapLeft
((
error: ParseResult.ParseError
error
) =>
import ParseResult
ParseResult
.
const ArrayFormatter: ParseResult.ParseResultFormatter<ParseResult.ArrayFormatterIssue[]>

@since3.10.0

ArrayFormatter
.
ParseResultFormatter<ArrayFormatterIssue[]>.formatErrorSync: (error: ParseResult.ParseError) => ParseResult.ArrayFormatterIssue[]
formatErrorSync
(
error: ParseResult.ParseError
error
)
)
),
null,
2
)
)
/*
"_id": "Either",
"_tag": "Left",
"left": [
{
"_tag": "Type",
"path": [
"confirm_password"
],
"message": "Passwords do not match"
}
]
}
*/

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)

import {
import Either

@since2.0.0

@since2.0.0

Either
,
import Schema
Schema
,
import ParseResult
ParseResult
} from "effect"
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.

@since3.10.0

Trim
.
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<...>

@since3.10.0

minLength
(2))
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>

@since3.10.0

optional
(
import Schema
Schema
.
class String
export String

@since3.10.0

String
)
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: {
password: Schema.filter<Schema.Schema<string, string, never>>;
confirm_password: Schema.filter<Schema.Schema<string, string, never>>;
name: Schema.optional<...>;
surname: Schema.optional<...>;
}): Schema.Struct<...> (+1 overload)

@since3.10.0

Struct
({
password: Schema.filter<Schema.Schema<string, string, never>>
password
:
const Password: Schema.filter<Schema.Schema<string, string, never>>
Password
,
confirm_password: Schema.filter<Schema.Schema<string, string, never>>
confirm_password
:
const Password: Schema.filter<Schema.Schema<string, string, never>>
Password
,
name: Schema.optional<typeof Schema.String>
name
:
const OptionalString: Schema.optional<typeof Schema.String>
OptionalString
,
surname: Schema.optional<typeof Schema.String>
surname
:
const OptionalString: Schema.optional<typeof Schema.String>
OptionalString
}).
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
(
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)

@since3.10.0

filter
((
input: {
readonly password: string;
readonly confirm_password: string;
readonly name?: string | undefined;
readonly surname?: string | undefined;
}
input
) => {
const
const issues: Schema.FilterIssue[]
issues
:
interface Array<T>
Array
<
import Schema
Schema
.
interface FilterIssue

@since3.10.0

FilterIssue
> = []
// Check if passwords match
if (
input: {
readonly password: string;
readonly confirm_password: string;
readonly name?: string | undefined;
readonly surname?: string | undefined;
}
input
.
password: string
password
!==
input: {
readonly password: string;
readonly confirm_password: string;
readonly name?: string | undefined;
readonly surname?: string | undefined;
}
input
.
confirm_password: string
confirm_password
) {
const issues: Schema.FilterIssue[]
issues
.
Array<FilterIssue>.push(...items: Schema.FilterIssue[]): number

Appends new elements to the end of an array, and returns the new length of the array.

@paramitems New elements to add to the array.

push
({
FilterIssue.path: readonly PropertyKey[]
path
: ["confirm_password"],
FilterIssue.message: string
message
: "Passwords do not match"
})
}
// Ensure either name or surname is present
if (!
input: {
readonly password: string;
readonly confirm_password: string;
readonly name?: string | undefined;
readonly surname?: string | undefined;
}
input
.
name?: string | undefined
name
&& !
input: {
readonly password: string;
readonly confirm_password: string;
readonly name?: string | undefined;
readonly surname?: string | undefined;
}
input
.
surname?: string | undefined
surname
) {
const issues: Schema.FilterIssue[]
issues
.
Array<FilterIssue>.push(...items: Schema.FilterIssue[]): number

Appends new elements to the end of an array, and returns the new length of the array.

@paramitems New elements to add to the array.

push
({
FilterIssue.path: readonly PropertyKey[]
path
: ["surname"],
FilterIssue.message: string
message
: "Surname must be present if name is not present"
})
}
return
const issues: Schema.FilterIssue[]
issues
})
)
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 and process.stderr. 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 for more information.

Example using the global console:

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:

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

@seesource

console
.
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) (the arguments are all passed to util.format()).

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() for more information.

@sincev0.1.100

log
(
var JSON: JSON

An intrinsic object that provides functions to convert JavaScript values to and from the JavaScript Object Notation (JSON) format.

JSON
.
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.

@paramvalue A JavaScript value, usually an object or array, to be converted.

@paramreplacer An array of strings and numbers that acts as an approved list for selecting the object properties that will be stringified.

@paramspace Adds indentation, white space, and line break characters to the return-value JSON text to make it easier to read.

stringify
(
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<...>

@since3.10.0

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
)({
password: string
password
: "abc",
confirm_password: string
confirm_password
: "d" // Confirm password does not match
}).
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
(
import Either

@since2.0.0

@since2.0.0

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.

@paramself - The input Either value to map.

@paramf - A transformation function to apply to the Left value of the input Either.

@since2.0.0

mapLeft
((
error: ParseResult.ParseError
error
) =>
import ParseResult
ParseResult
.
const ArrayFormatter: ParseResult.ParseResultFormatter<ParseResult.ArrayFormatterIssue[]>

@since3.10.0

ArrayFormatter
.
ParseResultFormatter<ArrayFormatterIssue[]>.formatErrorSync: (error: ParseResult.ParseError) => ParseResult.ArrayFormatterIssue[]
formatErrorSync
(
error: ParseResult.ParseError
error
)
)
),
null,
2
)
)
/*
{
"_id": "Either",
"_tag": "Left",
"left": [
{
"_tag": "Type",
"path": [
"confirm_password"
],
"message": "Passwords do not match"
},
{
"_tag": "Type",
"path": [
"surname"
],
"message": "Surname must be present if name is not present"
}
]
}
*/

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:

import {
import Schema
Schema
} from "effect"
const
const LongString: Schema.filter<typeof Schema.String>
LongString
=
import Schema
Schema
.
class String
export String

@since3.10.0

String
.
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
(
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)

@since3.10.0

filter
((
s: string
s
) =>
s: string
s
.
String.length: number

Returns the length of a String object.

length
>= 10)
)
// Access the base schema, which is the string schema
// before the filter was applied
//
// ┌─── typeof Schema.String
// ▼
const
const From: typeof Schema.String
From
=
const LongString: Schema.filter<typeof Schema.String>
LongString
.
refine<string, typeof String$>.from: typeof Schema.String
from

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

import {
import Schema
Schema
} from "effect"
// Specifies maximum length of a string
import Schema
Schema
.
class String
export String

@since3.10.0

String
.
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<...>

@since3.10.0

maxLength
(5))
// Specifies minimum length of a string
import Schema
Schema
.
class String
export String

@since3.10.0

String
.
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<...>

@since3.10.0

minLength
(5))
// Equivalent to ensuring the string has a minimum length of 1
import Schema
Schema
.
class NonEmptyString

@since3.10.0

NonEmptyString
// Specifies exact length of a string
import Schema
Schema
.
class String
export String

@since3.10.0

String
.
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<...>

@since3.10.0

length
(5))
// Specifies a range for the length of a string
import Schema
Schema
.
class String
export String

@since3.10.0

String
.
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<...>

@since3.10.0

length
({
min: number
min
: 2,
max: number
max
: 4 }))
// Matches a string against a regular expression pattern
import Schema
Schema
.
class String
export String

@since3.10.0

String
.
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<...>>

@since3.10.0

pattern
(/^[a-z]+$/))
// Ensures a string starts with a specific substring
import Schema
Schema
.
class String
export String

@since3.10.0

String
.
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<...>

@since3.10.0

startsWith
("prefix"))
// Ensures a string ends with a specific substring
import Schema
Schema
.
class String
export String

@since3.10.0

String
.
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<...>

@since3.10.0

endsWith
("suffix"))
// Checks if a string includes a specific substring
import Schema
Schema
.
class String
export String

@since3.10.0

String
.
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<...>

@since3.10.0

includes
("substring"))
// Validates that a string has no leading or trailing whitespaces
import Schema
Schema
.
class String
export String

@since3.10.0

String
.
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.

@since3.10.0

trimmed
())
// Validates that a string is entirely in lowercase
import Schema
Schema
.
class String
export String

@since3.10.0

String
.
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.

@since3.10.0

lowercased
())
// Validates that a string is entirely in uppercase
import Schema
Schema
.
class String
export String

@since3.10.0

String
.
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.

@since3.10.0

uppercased
())
// Validates that a string is capitalized
import Schema
Schema
.
class String
export String

@since3.10.0

String
.
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.

@since3.10.0

capitalized
())
// Validates that a string is uncapitalized
import Schema
Schema
.
class String
export String

@since3.10.0

String
.
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.

@since3.10.0

uncapitalized
())

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

import {
import Schema
Schema
} from "effect"
// Specifies a number greater than 5
import Schema
Schema
.
class Number
export Number

@since3.10.0

Number
.
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.

@since3.10.0

greaterThan
(5))
// Specifies a number greater than or equal to 5
import Schema
Schema
.
class Number
export Number

@since3.10.0

Number
.
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.

@since3.10.0

greaterThanOrEqualTo
(5))
// Specifies a number less than 5
import Schema
Schema
.
class Number
export Number

@since3.10.0

Number
.
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.

@since3.10.0

lessThan
(5))
// Specifies a number less than or equal to 5
import Schema
Schema
.
class Number
export Number

@since3.10.0

Number
.
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.

@since3.10.0

lessThanOrEqualTo
(5))
// Specifies a number between -2 and 2, inclusive
import Schema
Schema
.
class Number
export Number

@since3.10.0

Number
.
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.

@since3.10.0

between
(-2, 2))
// Specifies that the value must be an integer
import Schema
Schema
.
class Number
export Number

@since3.10.0

Number
.
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>>

@since3.10.0

int
())
// Ensures the value is not NaN
import Schema
Schema
.
class Number
export Number

@since3.10.0

Number
.
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>>

@since3.10.0

nonNaN
())
// Ensures the value is finite and not Infinity or -Infinity
import Schema
Schema
.
class Number
export Number

@since3.10.0

Number
.
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.

@since3.10.0

finite
())
// Specifies a positive number (> 0)
import Schema
Schema
.
class Number
export Number

@since3.10.0

Number
.
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>>

@since3.10.0

positive
())
// Specifies a non-negative number (>= 0)
import Schema
Schema
.
class Number
export Number

@since3.10.0

Number
.
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>>

@since3.10.0

nonNegative
())
// Specifies a negative number (< 0)
import Schema
Schema
.
class Number
export Number

@since3.10.0

Number
.
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>>

@since3.10.0

negative
())
// Specifies a non-positive number (<= 0)
import Schema
Schema
.
class Number
export Number

@since3.10.0

Number
.
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>>

@since3.10.0

nonPositive
())
// Specifies a number that is evenly divisible by 5
import Schema
Schema
.
class Number
export Number

@since3.10.0

Number
.
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<...>

@since3.10.0

multipleOf
(5))

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

import {
import Schema
Schema
} from "effect"
// Specifies the maximum number of items in the array
import Schema
Schema
.
Array<typeof Schema.Number>(value: typeof Schema.Number): Schema.Array$<typeof Schema.Number>
export Array

@since3.10.0

Array
(
import Schema
Schema
.
class Number
export Number

@since3.10.0

Number
).
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>>

@since3.10.0

maxItems
(2))
// Specifies the minimum number of items in the array
import Schema
Schema
.
Array<typeof Schema.Number>(value: typeof Schema.Number): Schema.Array$<typeof Schema.Number>
export Array

@since3.10.0

Array
(
import Schema
Schema
.
class Number
export Number

@since3.10.0

Number
).
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>>

@since3.10.0

minItems
(2))
// Specifies the exact number of items in the array
import Schema
Schema
.
Array<typeof Schema.Number>(value: typeof Schema.Number): Schema.Array$<typeof Schema.Number>
export Array

@since3.10.0

Array
(
import Schema
Schema
.
class Number
export Number

@since3.10.0

Number
).
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>>

@since3.10.0

itemsCount
(2))

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

import {
import Schema
Schema
} from "effect"
// Specifies a BigInt greater than 5
import Schema
Schema
.
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).

@since3.10.0

BigInt
.
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>>

@since3.10.0

greaterThanBigInt
(5n))
// Specifies a BigInt greater than or equal to 5
import Schema
Schema
.
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).

@since3.10.0

BigInt
.
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>>

@since3.10.0

greaterThanOrEqualToBigInt
(5n))
// Specifies a BigInt less than 5
import Schema
Schema
.
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).

@since3.10.0

BigInt
.
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>>

@since3.10.0

lessThanBigInt
(5n))
// Specifies a BigInt less than or equal to 5
import Schema
Schema
.
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).

@since3.10.0

BigInt
.
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>>

@since3.10.0

lessThanOrEqualToBigInt
(5n))
// Specifies a BigInt between -2n and 2n, inclusive
import Schema
Schema
.
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).

@since3.10.0

BigInt
.
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<...>

@since3.10.0

betweenBigInt
(-2n, 2n))
// Specifies a positive BigInt (> 0n)
import Schema
Schema
.
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).

@since3.10.0

BigInt
.
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>>

@since3.10.0

positiveBigInt
())
// Specifies a non-negative BigInt (>= 0n)
import Schema
Schema
.
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).

@since3.10.0

BigInt
.
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>>

@since3.10.0

nonNegativeBigInt
())
// Specifies a negative BigInt (< 0n)
import Schema
Schema
.
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).

@since3.10.0

BigInt
.
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>>

@since3.10.0

negativeBigInt
())
// Specifies a non-positive BigInt (<= 0n)
import Schema
Schema
.
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).

@since3.10.0

BigInt
.
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>>

@since3.10.0

nonPositiveBigInt
())

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

import {
import Schema
Schema
} from "effect"
import {
import BigDecimal
BigDecimal
} from "effect"
// Specifies a BigDecimal greater than 5
import Schema
Schema
.
class BigDecimal

@since3.10.0

BigDecimal
.
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 greaterThanBigDecimal: <BigDecimal.BigDecimal>(min: BigDecimal.BigDecimal, annotations?: Schema.Annotations.Filter<BigDecimal.BigDecimal, BigDecimal.BigDecimal> | undefined) => <I, R>(self: Schema.Schema<...>) => Schema.filter<...>

@since3.10.0

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.

Throws a RangeError if the number is not finite (NaN, +Infinity or -Infinity).

@paramvalue - The number value to create a BigDecimal from.

@since2.0.0

@deprecatedUse unsafeFromNumber instead.

fromNumber
(5))
)
// Specifies a BigDecimal greater than or equal to 5
import Schema
Schema
.
class BigDecimal

@since3.10.0

BigDecimal
.
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 greaterThanOrEqualToBigDecimal: <BigDecimal.BigDecimal>(min: BigDecimal.BigDecimal, annotations?: Schema.Annotations.Filter<BigDecimal.BigDecimal, BigDecimal.BigDecimal> | undefined) => <I, R>(self: Schema.Schema<...>) => Schema.filter<...>

@since3.10.0

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.

Throws a RangeError if the number is not finite (NaN, +Infinity or -Infinity).

@paramvalue - The number value to create a BigDecimal from.

@since2.0.0

@deprecatedUse unsafeFromNumber instead.

fromNumber
(5))
)
// Specifies a BigDecimal less than 5
import Schema
Schema
.
class BigDecimal

@since3.10.0

BigDecimal
.
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 lessThanBigDecimal: <BigDecimal.BigDecimal>(max: BigDecimal.BigDecimal, annotations?: Schema.Annotations.Filter<BigDecimal.BigDecimal, BigDecimal.BigDecimal> | undefined) => <I, R>(self: Schema.Schema<...>) => Schema.filter<...>

@since3.10.0

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.

Throws a RangeError if the number is not finite (NaN, +Infinity or -Infinity).

@paramvalue - The number value to create a BigDecimal from.

@since2.0.0

@deprecatedUse unsafeFromNumber instead.

fromNumber
(5))
)
// Specifies a BigDecimal less than or equal to 5
import Schema
Schema
.
class BigDecimal

@since3.10.0

BigDecimal
.
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 lessThanOrEqualToBigDecimal: <BigDecimal.BigDecimal>(max: BigDecimal.BigDecimal, annotations?: Schema.Annotations.Filter<BigDecimal.BigDecimal, BigDecimal.BigDecimal> | undefined) => <I, R>(self: Schema.Schema<...>) => Schema.filter<...>

@since3.10.0

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.

Throws a RangeError if the number is not finite (NaN, +Infinity or -Infinity).

@paramvalue - The number value to create a BigDecimal from.

@since2.0.0

@deprecatedUse unsafeFromNumber instead.

fromNumber
(5))
)
// Specifies a BigDecimal between -2 and 2, inclusive
import Schema
Schema
.
class BigDecimal

@since3.10.0

BigDecimal
.
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 betweenBigDecimal: <BigDecimal.BigDecimal>(minimum: BigDecimal.BigDecimal, maximum: BigDecimal.BigDecimal, annotations?: Schema.Annotations.Filter<...> | undefined) => <I, R>(self: Schema.Schema<...>) => Schema.filter<...>

@since3.10.0

betweenBigDecimal
(
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.

Throws a RangeError if the number is not finite (NaN, +Infinity or -Infinity).

@paramvalue - The number value to create a BigDecimal from.

@since2.0.0

@deprecatedUse unsafeFromNumber instead.

fromNumber
(-2),
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.

Throws a RangeError if the number is not finite (NaN, +Infinity or -Infinity).

@paramvalue - The number value to create a BigDecimal from.

@since2.0.0

@deprecatedUse unsafeFromNumber instead.

fromNumber
(2)
)
)
// Specifies a positive BigDecimal (> 0)
import Schema
Schema
.
class BigDecimal

@since3.10.0

BigDecimal
.
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<...>

@since3.10.0

positiveBigDecimal
())
// Specifies a non-negative BigDecimal (>= 0)
import Schema
Schema
.
class BigDecimal

@since3.10.0

BigDecimal
.
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<...>

@since3.10.0

nonNegativeBigDecimal
())
// Specifies a negative BigDecimal (< 0)
import Schema
Schema
.
class BigDecimal

@since3.10.0

BigDecimal
.
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<...>

@since3.10.0

negativeBigDecimal
())
// Specifies a non-positive BigDecimal (<= 0)
import Schema
Schema
.
class BigDecimal

@since3.10.0

BigDecimal
.
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<...>

@since3.10.0

nonPositiveBigDecimal
())

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

import {
import Schema
Schema
} from "effect"
// Specifies a duration greater than 5 seconds
import Schema
Schema
.
class Duration

A schema that transforms a [number, number] tuple into a Duration.

@since3.10.0

Duration
.
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<...>

@since3.10.0

greaterThanDuration
("5 seconds"))
// Specifies a duration greater than or equal to 5 seconds
import Schema
Schema
.
class Duration

A schema that transforms a [number, number] tuple into a Duration.

@since3.10.0

Duration
.
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<...>

@since3.10.0

greaterThanOrEqualToDuration
("5 seconds"))
// Specifies a duration less than 5 seconds
import Schema
Schema
.
class Duration

A schema that transforms a [number, number] tuple into a Duration.

@since3.10.0

Duration
.
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<...>

@since3.10.0

lessThanDuration
("5 seconds"))
// Specifies a duration less than or equal to 5 seconds
import Schema
Schema
.
class Duration

A schema that transforms a [number, number] tuple into a Duration.

@since3.10.0

Duration
.
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<...>

@since3.10.0

lessThanOrEqualToDuration
("5 seconds"))
// Specifies a duration between 5 seconds and 10 seconds, inclusive
import Schema
Schema
.
class Duration

A schema that transforms a [number, number] tuple into a Duration.

@since3.10.0

Duration
.
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<...>

@since3.10.0

betweenDuration
("5 seconds", "10 seconds"))