-
Hi, I was making a schema where i used Taking the following example: I want const firstSchema = Type.Union([
Type.Object(
{
statecode: Type.Literal(0)
},
{ additionalProperties: false }
),
Type.Object(
{
statecode: Type.Union([Type.Literal(1), Type.Literal(2)]),
statuscode: Type.Number()
},
{ additionalProperties: false }
)
]); When i validate the value using the above schema on its own it works as expected. console.log({
a: Value.Decode(firstSchema, [], { statecode: 1, statuscode: 12234234 }),
b: Value.Decode(firstSchema, [], { statecode: 0 })
});
// { a: { statecode: 1, statuscode: 12234234 }, b: { statecode: 0 } } But as soon i include the above union schema in a const secondSchema = Type.Composite([
firstSchema,
Type.Object({
accountid: Type.String({
format: 'uuid',
}),
})
]);
console.log({
a: Value.Decode(secondSchema, [], { statecode: 1, accountid: '7731c8b9-15a0-452d-b237-e9f5210d40d4' }),
});
// { a: { statecode: 1, accountid: '7731c8b9-15a0-452d-b237-e9f5210d40d4' } } This validation should give error because |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Got the answer for now #894 |
Beta Was this translation helpful? Give feedback.
Got the answer for now #894