Uint8ArrayType-level representation of Uint8Array.
export interface Uint8Array 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.interface Uint8Array<TArrayBuffer extends ArrayBufferLike = ArrayBufferLike>A typed array of 8-bit unsigned integer values. The contents are initialized to 0. If the
requested number of bytes could not be allocated an exception is raised.
Uint8Array<type ArrayBufferLike =
| ArrayBuffer
| SharedArrayBuffer
ArrayBufferLike>> {
readonly "Rebuild": Uint8Array
}
const const Base64String: Stringconst Base64String: {
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; <…;
}
Base64String = 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 base64 encoded string that will be decoded as Uint8Array",
Annotations.Augment.format?: string | undefinedformat: "byte",
Annotations.Augment.contentEncoding?: string | undefinedcontentEncoding: "base64"
})
/**
* Schema for JavaScript `Uint8Array` objects.
*
* **Details**
*
* Default JSON serializer:
*
* The default JSON serializer encodes Uint8Array as a Base64 encoded string.
*
* @category Uint8Array
* @since 4.0.0
*/
export const const Uint8Array: Uint8Arrayconst Uint8Array: {
Rebuild: Uint8Array;
Iso: Iso;
ast: Ast;
Type: T;
Encoded: E;
DecodingServices: RD;
EncodingServices: RE;
annotate: (annotations: Annotations.Bottom<globalThis.Uint8Array<ArrayBufferLike>, readonly []>) => Uint8Array;
annotateKey: (annotations: Annotations.Key<globalThis.Uint8Array<ArrayBufferLike>>) => Uint8Array;
check: (checks_0: SchemaAST.Check<globalThis.Uint8Array<ArrayBufferLike>>, ...checks: Array<SchemaAST.Check<globalThis.Uint8Array<ArrayBufferLike>>>) => Uint8Array;
rebuild: (ast: SchemaAST.Declaration) => Uint8Array;
make: (input: globalThis.Uint8Array<ArrayBufferLike>, options?: MakeOptions) => globalThis.Uint8Array<ArrayBufferLike>;
makeOption: (input: globalThis.Uint8Array<ArrayBufferLike>, options?: MakeOptions) => Option_.Option<globalThis.Uint8Array<ArrayBufferLike>>;
makeEffect: (input: globalThis.Uint8Array<ArrayBufferLike>, options?: MakeOptions) => Effect.Effect<globalThis.Uint8Array<ArrayBufferLike>, 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
Uint8Array
.
Schema for JavaScript Uint8Array objects.
Details
Default JSON serializer:
The default JSON serializer encodes Uint8Array as a Base64 encoded string.
Uint8Array: Uint8Array = 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 Uint8Array: Uint8ArrayConstructorA typed array of 8-bit unsigned integer values. The contents are initialized to 0. If the
requested number of bytes could not be allocated an exception is raised.
Uint8Array<type ArrayBufferLike =
| ArrayBuffer
| SharedArrayBuffer
ArrayBufferLike>, {
Annotations.Declaration<globalThis.Uint8Array<ArrayBufferLike>, readonly []>.typeConstructor?: {
readonly [key: string]: unknown;
readonly _tag: string;
} | undefined
typeConstructor: {
_tag: string_tag: "Uint8Array"
},
Annotations.Declaration<globalThis.Uint8Array<ArrayBufferLike>, readonly []>.generation?: {
readonly runtime: string;
readonly Type: string;
readonly Encoded?: string | undefined;
readonly importDeclaration?: string | undefined;
} | undefined
generation: {
runtime: stringruntime: `Schema.Uint8Array`,
type Type: stringType: `globalThis.Uint8Array`
},
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: "Uint8Array",
Annotations.Declaration<globalThis.Uint8Array<ArrayBufferLike>, 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.interface Uint8Array<TArrayBuffer extends ArrayBufferLike = ArrayBufferLike>A typed array of 8-bit unsigned integer values. The contents are initialized to 0. If the
requested number of bytes could not be allocated an exception is raised.
Uint8Array<type ArrayBufferLike =
| ArrayBuffer
| SharedArrayBuffer
ArrayBufferLike>>()(
const Base64String: Stringconst Base64String: {
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; <…;
}
Base64String,
import SchemaTransformationSchemaTransformation.const uint8ArrayFromBase64String: Transformation<
Uint8Array<ArrayBufferLike>,
string
>
const uint8ArrayFromBase64String: {
_tag: 'Transformation';
decode: SchemaGetter.Getter<T, E, RD>;
encode: SchemaGetter.Getter<E, T, RE>;
flip: () => SchemaTransformation.Transformation<string, globalThis.Uint8Array<ArrayBufferLike>, never, never>;
compose: (other: SchemaTransformation.Transformation<T2, globalThis.Uint8Array<ArrayBufferLike>, RD2, RE2>) => SchemaTransformation.Transformation<T2, string, RD2, RE2>;
}
Decodes a Base64-encoded string into a Uint8Array and encodes a
Uint8Array back to a Base64 string.
When to use
Use when you need a schema transformation for binary data transmitted as
Base64 strings (e.g. file uploads, API payloads).
Details
Decoding parses the Base64 string into bytes. Encoding writes the byte array
as a Base64 string.
Example (Converting Base64 to a Uint8Array)
import { Schema, SchemaTransformation } from "effect"
const schema = Schema.String.pipe(
Schema.decodeTo(Schema.Uint8Array, SchemaTransformation.uint8ArrayFromBase64String)
)
uint8ArrayFromBase64String
),
Annotations.Declaration<globalThis.Uint8Array<ArrayBufferLike>, readonly []>.toArbitrary?: Annotations.ToArbitrary.Declaration<globalThis.Uint8Array<ArrayBufferLike>, readonly []> | undefinedtoArbitrary: () => (fc: typeof FastCheckfc) => fc: typeof FastCheckfc.uint8Array()
})