Effect CommunityEC
Effect Community2y ago
7 replies
DaMuffinx

Understanding Schema.is Behavior in JSON Parsing

can anyone explain to me why Schema.is behaves this way? maybe i'm misunderstanding, but it seems that it should return true in this case?

import {Schema } from "@effect/schema"

const mySchema = Schema.parseJson(Schema.Struct({name: Schema.String}))
const json = `{"name": "john"}`

const isIt = Schema.is(mySchema)(json)
console.log(isIt) // false

const parsed = Schema.decodeSync(mySchema)(json)
console.log(parsed) // { name: 'john' }
Was this page helpful?