jointz
jointz copied to clipboard
combine two object validators
Hi
How do I join to validators?
const a = jointz.object({ c: jointz.string() });
const b = jointz.object({ d: jointz.string() });
How to do a validator with type
type ab = { c: string; d: string; }
and operator needed
As when we do it typescript type TAB = A & B
There is no method to combine two object validators. You can do something like this though
const aFields = { c: jointz.string() };
const bFields = { d: jointz.string() };
const ab = jointz.object({...aFields, ...bFields})
I added #extend
, #pick
, #omit
, which helps, but not exactly combine like you asked 😅