Is array contains supported? #438
-
https://json-schema.org/understanding-json-schema/reference/array.html#contains
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
@joshuaavalon Hi, TypeBox doesn't expose the The following is fine if using Ajv. // Expect an array of numbers, one or more should be equal to 1.
const T = Type.Array(Type.Number(), {
contains: Type.Literal(1),
}) Maybe I should implement type checker support for this keyword? (There's some considering going into implement additional keywords that mean little to TS, but can be useful on the validation side, other examples include Hope this helps |
Beta Was this translation helpful? Give feedback.
@joshuaavalon Hi,
TypeBox doesn't expose the
contains
keyword (currently) as it's not supported in the type checkers, however you are still free to specify thecontains
keyword (as well asminContains
andmaxContains
) on theArrayOptions
.The following is fine if using Ajv.
Maybe I should implement type checker support for this keyword? (There's some considering going into implement additional keywords that mean little to TS, but can be useful on the validation side, other examples include
if/then/else
,dependentRequired
etc)Hope this helps
S