import { Schema } from '@effect/schema';
class Person extends Schema.Class<Person>('Person')({
id: Schema.Number,
name: Schema.Trim,
}) {}
const johnny = new Person({ id: 1, name: ' johnny ' }); // throws error
const john = Schema.decodeUnknownSync(Person)({ id: 1, name: ' john ' }); // does not throw
console.log(johnny);
console.log(john);
import { Schema } from '@effect/schema';
class Person extends Schema.Class<Person>('Person')({
id: Schema.Number,
name: Schema.Trim,
}) {}
const johnny = new Person({ id: 1, name: ' johnny ' }); // throws error
const john = Schema.decodeUnknownSync(Person)({ id: 1, name: ' john ' }); // does not throw
console.log(johnny);
console.log(john);