import { Secret } from 'effect'
import { Schema } from "@effect/schema"
const schema = Schema.Trimmed.pipe(Schema.compose(Schema.Secret))
console.log(Schema.decodeUnknown(schema)(' 123'))
console.log(Schema.encodeEither(schema)(Secret.fromString(' 123')))
/*
{
_id: 'Either',
_tag: 'Left',
left: {
_id: 'ParseError',
message: '(Trimmed <-> Secret)\n' +
'└─ Encoded side transformation failure\n' +
' └─ Trimmed\n' +
' └─ Predicate refinement failure\n' +
' └─ Expected Trimmed (a string with no leading or trailing whitespace), actual " 123"'
}
}
{
_id: 'Either',
_tag: 'Left',
left: {
_id: 'ParseError',
message: '(Trimmed <-> Secret)\n' +
'└─ Encoded side transformation failure\n' +
' └─ Trimmed\n' +
' └─ Predicate refinement failure\n' +
' └─ Expected Trimmed (a string with no leading or trailing whitespace), actual " 123"'
}
}
*/
import { Secret } from 'effect'
import { Schema } from "@effect/schema"
const schema = Schema.Trimmed.pipe(Schema.compose(Schema.Secret))
console.log(Schema.decodeUnknown(schema)(' 123'))
console.log(Schema.encodeEither(schema)(Secret.fromString(' 123')))
/*
{
_id: 'Either',
_tag: 'Left',
left: {
_id: 'ParseError',
message: '(Trimmed <-> Secret)\n' +
'└─ Encoded side transformation failure\n' +
' └─ Trimmed\n' +
' └─ Predicate refinement failure\n' +
' └─ Expected Trimmed (a string with no leading or trailing whitespace), actual " 123"'
}
}
{
_id: 'Either',
_tag: 'Left',
left: {
_id: 'ParseError',
message: '(Trimmed <-> Secret)\n' +
'└─ Encoded side transformation failure\n' +
' └─ Trimmed\n' +
' └─ Predicate refinement failure\n' +
' └─ Expected Trimmed (a string with no leading or trailing whitespace), actual " 123"'
}
}
*/