How logical composition works in fluent-json-schema
mainThe library allows building complex validation logic using standard JSON Schema logical operators. These methods return a BaseSchema and accept arrays of other schemas:
anyOf(schemas): Logical OR. Valid if any schema matches.allOf(schemas): Logical AND. Valid if all schemas match.oneOf(schemas): Logical XOR. Valid if exactly one schema matches.not(schema): Logical NOT. Valid if the instance fails the provided schema.ifThenElse(if, then, else): Conditional logic. If theifschema matches, the instance must then match thethenschema; otherwise, it must match theelseschema.
S.anyOf([S.string(), S.number()])