typia icon indicating copy to clipboard operation
typia copied to clipboard

tag for not in logic (exclude)

Open salisbury-espinosa opened this issue 6 months ago • 2 comments

interface SomeType {
  someField: number & tags.exclude<1 | 2 | 10>;
}

or

interface SomeType {
  someField: string & tags.exclude<'someInvalidStringOne' | 'someInvalidStringTwo'>;
}

salisbury-espinosa avatar Aug 04 '25 13:08 salisbury-espinosa

{
  "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>;

samchon avatar Aug 05 '25 03:08 samchon

Researching JSON schema's not property, but its spec is super-wide, so needs to adapt only few things.

samchon avatar Aug 08 '25 14:08 samchon