URLSearchParamsType-level representation of URLSearchParams.
export interface URLSearchParams extends interface instanceOf<T, Iso = T>Creates a schema that validates values using instanceof.
Decoding and encoding pass the value through unchanged.
Example (Defining a schema for a built-in class)
import { Schema } from "effect"
const DateSchema = Schema.instanceOf(Date)
const decoded = Schema.decodeUnknownSync(DateSchema)(new Date("2024-01-01"))
// decoded: Date
Type-level representation returned by
instanceOf
.
instanceOf<module globalThisglobalThis.URLSearchParams> {
readonly "Rebuild": URLSearchParams
}
/**
* Schema for JavaScript `URLSearchParams` objects.
*
* **Details**
*
* The default JSON serializer encodes a `URLSearchParams` as a query string.
*
* @category search params
* @since 4.0.0
*/
export const const URLSearchParams: URLSearchParamsconst URLSearchParams: {
Rebuild: URLSearchParams;
Iso: Iso;
ast: Ast;
Type: T;
Encoded: E;
DecodingServices: RD;
EncodingServices: RE;
annotate: (annotations: Annotations.Bottom<globalThis.URLSearchParams, readonly []>) => URLSearchParams;
annotateKey: (annotations: Annotations.Key<globalThis.URLSearchParams>) => URLSearchParams;
check: (checks_0: SchemaAST.Check<globalThis.URLSearchParams>, ...checks: Array<SchemaAST.Check<globalThis.URLSearchParams>>) => URLSearchParams;
rebuild: (ast: SchemaAST.Declaration) => URLSearchParams;
make: (input: globalThis.URLSearchParams, options?: MakeOptions) => globalThis.URLSearchParams;
makeOption: (input: globalThis.URLSearchParams, options?: MakeOptions) => Option_.Option<globalThis.URLSearchParams>;
makeEffect: (input: globalThis.URLSearchParams, options?: MakeOptions) => Effect.Effect<globalThis.URLSearchParams, SchemaError, never>;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
}
Type-level representation of
URLSearchParams
.
Schema for JavaScript URLSearchParams objects.
Details
The default JSON serializer encodes a URLSearchParams as a query string.
URLSearchParams: URLSearchParams = function instanceOf<
C extends abstract new (...args: any) => any,
Iso = InstanceType<C>
>(
constructor: C,
annotations?:
| Annotations.Declaration<InstanceType<C>>
| undefined
): instanceOf<InstanceType<C>, Iso>
Creates a schema that validates values using instanceof.
Decoding and encoding pass the value through unchanged.
Example (Defining a schema for a built-in class)
import { Schema } from "effect"
const DateSchema = Schema.instanceOf(Date)
const decoded = Schema.decodeUnknownSync(DateSchema)(new Date("2024-01-01"))
// decoded: Date
instanceOf(module globalThisglobalThis.var URLSearchParams: {
new (
init?:
| string[][]
| Record<string, string>
| string
| globalThis.URLSearchParams
): globalThis.URLSearchParams
prototype: globalThis.URLSearchParams
}
The URLSearchParams interface defines utility methods to work with the query string of a URL.
URLSearchParams, {
Annotations.Declaration<globalThis.URLSearchParams, readonly []>.typeConstructor?: {
readonly [key: string]: unknown;
readonly _tag: string;
} | undefined
typeConstructor: {
_tag: string_tag: "URLSearchParams"
},
Annotations.Declaration<globalThis.URLSearchParams, readonly []>.generation?: {
readonly runtime: string;
readonly Type: string;
readonly Encoded?: string | undefined;
readonly importDeclaration?: string | undefined;
} | undefined
generation: {
runtime: stringruntime: `Schema.URLSearchParams`,
type Type: stringType: `globalThis.URLSearchParams`
},
Annotations.Augment.expected?: string | undefinedHuman-readable description of what a value is expected to satisfy.
Details
For filter and refinement failures, the default formatter uses
message first, then expected, and finally falls back to <filter>.
Use this to name a failed filter in the default message:
Expected <expected>, got <actual>.
expected: "URLSearchParams",
Annotations.Declaration<globalThis.URLSearchParams, readonly []>.toCodecJson?: ((typeParameters: readonly []) => SchemaAST.Link) | undefinedtoCodecJson: () =>
function link<T>(): <
To extends Constraint
>(
encodeTo: To,
transformation: {
readonly decode: SchemaGetter.Getter<
T,
NoInfer<To["Type"]>
>
readonly encode: SchemaGetter.Getter<
NoInfer<To["Type"]>,
T
>
}
) => SchemaAST.Link
Constructs an SchemaAST.Link that describes how a value of type T encodes to and decodes from a To schema.
Used when building low-level AST transformations that bridge two schema types.
link<module globalThisglobalThis.URLSearchParams>()(
const String: Stringconst String: {
Rebuild: Rebuild;
Iso: Iso;
ast: Ast;
Type: T;
Encoded: E;
DecodingServices: RD;
EncodingServices: RE;
annotate: (annotations: Annotations.Bottom<string, readonly []>) => String;
annotateKey: (annotations: Annotations.Key<string>) => String;
check: (checks_0: SchemaAST.Check<string>, ...checks: Array<SchemaAST.Check<string>>) => String;
rebuild: (ast: SchemaAST.String) => String;
make: (input: string, options?: MakeOptions) => string;
makeOption: (input: string, options?: MakeOptions) => Option_.Option<string>;
makeEffect: (input: string, options?: MakeOptions) => Effect.Effect<string, SchemaError, never>;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
}
Type-level representation of
String
.
Schema for string values. Validates that the input is typeof "string".
String.Bottom<string, string, never, never, String, String, string, string, readonly [], string, "readonly", "required", "no-default", "readonly", "required">.annotate(annotations: Annotations.Bottom<string, readonly []>): Stringannotate({ Annotations.Augment.expected?: string | undefinedHuman-readable description of what a value is expected to satisfy.
Details
For filter and refinement failures, the default formatter uses
message first, then expected, and finally falls back to <filter>.
Use this to name a failed filter in the default message:
Expected <expected>, got <actual>.
expected: "a query string that will be decoded as URLSearchParams" }),
import SchemaTransformationSchemaTransformation.function transform<T, E>(options: {
readonly decode: (input: E) => T
readonly encode: (input: T) => E
}): Transformation<T, E>
Creates a Transformation from pure (sync, infallible) decode and encode
functions.
When to use
Use when you need an infallible schema transformation that does not require
Effect services.
Details
- Each function receives the input and returns the output directly.
- Skips
None inputs (missing keys) — functions are only called on present values.
- Does not allocate Effects internally; uses optimized sync path.
Example (Converting between cents and dollars)
import { Schema, SchemaTransformation } from "effect"
const CentsFromDollars = Schema.Number.pipe(
Schema.decodeTo(
Schema.Number,
SchemaTransformation.transform({
decode: (dollars) => dollars * 100,
encode: (cents) => cents / 100
})
)
)
transform({
decode: (
input: string
) => globalThis.URLSearchParams
decode: (e: stringe) => new module globalThisglobalThis.var URLSearchParams: new (
init?:
| string[][]
| Record<string, string>
| string
| globalThis.URLSearchParams
) => globalThis.URLSearchParams
The URLSearchParams interface defines utility methods to work with the query string of a URL.
URLSearchParams(e: stringe),
encode: (
input: globalThis.URLSearchParams
) => string
encode: (params: globalThis.URLSearchParamsparams) => params: globalThis.URLSearchParamsparams.URLSearchParams.toString(): stringtoString()
})
)
})