Resolve payload — look up a winning claim by resource key (nodeless clients).
export class class ResolveRequestclass ResolveRequest {
key: string;
}
Resolve payload — look up a winning claim by resource key (nodeless clients).
ResolveRequest extends import SchemaSchema.const Class: <ResolveRequest, {}>(identifier: string) => {
<Fields>(fields: Fields, annotations?: Schema.Annotations.Declaration<ResolveRequest, readonly [Schema.Struct<Fields>]> | undefined): Schema.Class<ResolveRequest, Schema.Struct<Fields>, {}>;
<S>(schema: S, annotations?: Schema.Annotations.Declaration<ResolveRequest, readonly [S]> | undefined): Schema.Class<ResolveRequest, S, {}>;
}
Creates a schema-backed class whose constructor validates input against a
Struct
schema. Construction throws a
SchemaError
on invalid
input.
When to use
Use when you need a schema-backed data class with validated construction,
schema-derived decoding/encoding, and class-style methods or inheritance.
Details
Pass the desired class type as the first type parameter. The second optional
type parameter can be used to add nominal brands.
Gotchas
Passing disableChecks in the options skips constructor validation.
Example (Defining a basic class)
import { Schema } from "effect"
class Person extends Schema.Class<Person>("Person")({
name: Schema.String,
age: Schema.Number
}) {}
const alice = new Person({ name: "Alice", age: 30 })
console.log(alice.name) // "Alice"
console.log(`${alice}`) // "Person({ name: Alice, age: 30 })"
Example (Extending a class)
import { Schema } from "effect"
class Animal extends Schema.Class<Animal>("Animal")({
name: Schema.String
}) {}
class Dog extends Animal.extend<Dog>("Dog")({
breed: Schema.String
}) {}
const dog = new Dog({ name: "Rex", breed: "Labrador" })
console.log(dog.name) // "Rex"
console.log(dog.breed) // "Labrador"
Class<class ResolveRequestclass ResolveRequest {
key: string;
}
Resolve payload — look up a winning claim by resource key (nodeless clients).
ResolveRequest>("LookupResolveRequest")({
key: Schema.String(property) key: {
Rebuild: Rebuild;
Iso: Iso;
ast: Ast;
Type: T;
Encoded: E;
DecodingServices: RD;
EncodingServices: RE;
annotate: (annotations: Schema.Annotations.Bottom<string, readonly []>) => Schema.String;
annotateKey: (annotations: Schema.Annotations.Key<string>) => Schema.String;
check: (checks_0: Check<string>, ...checks: Array<Check<string>>) => Schema.String;
rebuild: (ast: String) => Schema.String;
make: (input: string, options?: Schema.MakeOptions) => string;
makeOption: (input: string, options?: Schema.MakeOptions) => Option.Option<string>;
makeEffect: (input: string, options?: Schema.MakeOptions) => Effect.Effect<string, Schema.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; <…;
}
key: import SchemaSchema.const String: Schema.Stringconst String: {
Rebuild: Rebuild;
Iso: Iso;
ast: Ast;
Type: T;
Encoded: E;
DecodingServices: RD;
EncodingServices: RE;
annotate: (annotations: Schema.Annotations.Bottom<string, readonly []>) => Schema.String;
annotateKey: (annotations: Schema.Annotations.Key<string>) => Schema.String;
check: (checks_0: Check<string>, ...checks: Array<Check<string>>) => Schema.String;
rebuild: (ast: String) => Schema.String;
make: (input: string, options?: Schema.MakeOptions) => string;
makeOption: (input: string, options?: Schema.MakeOptions) => Option.Option<string>;
makeEffect: (input: string, options?: Schema.MakeOptions) => Effect.Effect<string, Schema.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,
}) {}