typia
typia copied to clipboard
tag for not in logic (exclude)
interface SomeType {
someField: number & tags.exclude<1 | 2 | 10>;
}
or
interface SomeType {
someField: string & tags.exclude<'someInvalidStringOne' | 'someInvalidStringTwo'>;
}
{
"type": "object",
"properties": {
"someField": {
"type": "number",
"not": {
"oneOf": [
{ "const": 1 },
{ "const": 2 },
{ "const": 10 }
]
}
}
}
}
This is actually supported by JSON schema specification, so I'll try this at next week.
Also, as JSON schema uses the not keyword, I'll name it in such way.
const x: number & tags.Not<1 | 2 | 10>;
Researching JSON schema's not property, but its spec is super-wide, so needs to adapt only few things.