JSON Schema

Types

exception jsonlogic.json_schema.types.UnsupportedOperation
jsonlogic.json_schema.types.unpack_union(func: Callable[[JSONSchemaTypeT, TypeAliasForwardRef('JSONSchemaPrimitiveType'), TypeAliasForwardRef('BinaryOp')], JSONSchemaType], /) Callable[[JSONSchemaTypeT, JSONSchemaType, TypeAliasForwardRef('BinaryOp')], JSONSchemaType]

A utility decorator to unpack types of UnionType when calling JSONSchemaType.binary_op().

If other is a UnionType, each type of the union will be recursively applied to the binary_op() method.

class jsonlogic.json_schema.types.JSONSchemaType
abstract property name: str

The verbose name of the type to be used in diagnostic messages.

abstractmethod binary_op(other: JSONSchemaType, op: BinaryOp, /) JSONSchemaType

Get the resulting type of the binary operation with the other provided type.

Parameters:
  • other – The right hand operand of the operation.

  • op – The string representation of the operator.

Returns:

The return type of the operation.

Raises:

UnsupportedOperation – The operator is unsupported for the operands

abstractmethod unary_op(op: UnaryOp) JSONSchemaType

Get the resulting type of the unary operation.

Parameters:

op – The string representation of the operator.

Returns:

The return type of the operation.

Raises:

UnsupportedOperation – The operator is unsupported for the current type.

class jsonlogic.json_schema.types.UnionType(type: JSONSchemaTypeT, /)
class jsonlogic.json_schema.types.UnionType(type: JSONSchemaPrimitiveTypeT, *types: JSONSchemaPrimitiveTypeT)
class jsonlogic.json_schema.types.UnionType(type: JSONSchemaType, *types: JSONSchemaType)
property name: str

The verbose name of the type to be used in diagnostic messages.

binary_op(other: JSONSchemaType, op: BinaryOp) JSONSchemaType

Get the resulting type of the binary operation with the other provided type.

Parameters:
  • other – The right hand operand of the operation.

  • op – The string representation of the operator.

Returns:

The return type of the operation.

Raises:

UnsupportedOperation – The operator is unsupported for the operands

unary_op(op: UnaryOp) JSONSchemaType

Get the resulting type of the unary operation.

Parameters:

op – The string representation of the operator.

Returns:

The return type of the operation.

Raises:

UnsupportedOperation – The operator is unsupported for the current type.

class jsonlogic.json_schema.types.JSONSchemaPrimitiveType

A JSON Schema type other than UnionType.

class jsonlogic.json_schema.types.ArrayType(elements_type: 'JSONSchemaTypeT')
elements_type: JSONSchemaTypeT

The type of the elements of the array.

property name: str

The verbose name of the type to be used in diagnostic messages.

binary_op(other: JSONSchemaType, op: BinaryOp) NoReturn

Get the resulting type of the binary operation with the other provided type.

Parameters:
  • other – The right hand operand of the operation.

  • op – The string representation of the operator.

Returns:

The return type of the operation.

Raises:

UnsupportedOperation – The operator is unsupported for the operands

unary_op(op: UnaryOp) JSONSchemaType

Get the resulting type of the unary operation.

Parameters:

op – The string representation of the operator.

Returns:

The return type of the operation.

Raises:

UnsupportedOperation – The operator is unsupported for the current type.

class jsonlogic.json_schema.types.TupleType(tuple_types: 'tuple[Unpack[TupleTs]]')
tuple_types: tuple[Unpack[TupleTs]]

The types of the tuple.

property name: str

The verbose name of the type to be used in diagnostic messages.

binary_op(other: JSONSchemaType, op: BinaryOp) NoReturn

Get the resulting type of the binary operation with the other provided type.

Parameters:
  • other – The right hand operand of the operation.

  • op – The string representation of the operator.

Returns:

The return type of the operation.

Raises:

UnsupportedOperation – The operator is unsupported for the operands

unary_op(op: UnaryOp) JSONSchemaType

Get the resulting type of the unary operation.

Parameters:

op – The string representation of the operator.

Returns:

The return type of the operation.

Raises:

UnsupportedOperation – The operator is unsupported for the current type.

class jsonlogic.json_schema.types.AnyType
property name: str

The verbose name of the type to be used in diagnostic messages.

binary_op(other: JSONSchemaType, op: BinaryOp) JSONSchemaType

Get the resulting type of the binary operation with the other provided type.

Parameters:
  • other – The right hand operand of the operation.

  • op – The string representation of the operator.

Returns:

The return type of the operation.

Raises:

UnsupportedOperation – The operator is unsupported for the operands

unary_op(op: UnaryOp) JSONSchemaType

Get the resulting type of the unary operation.

Parameters:

op – The string representation of the operator.

Returns:

The return type of the operation.

Raises:

UnsupportedOperation – The operator is unsupported for the current type.

class jsonlogic.json_schema.types.BooleanType
property name: str

The verbose name of the type to be used in diagnostic messages.

binary_op(other: JSONSchemaType, op: BinaryOp) NoReturn

Get the resulting type of the binary operation with the other provided type.

Parameters:
  • other – The right hand operand of the operation.

  • op – The string representation of the operator.

Returns:

The return type of the operation.

Raises:

UnsupportedOperation – The operator is unsupported for the operands

unary_op(op: UnaryOp) JSONSchemaType

Get the resulting type of the unary operation.

Parameters:

op – The string representation of the operator.

Returns:

The return type of the operation.

Raises:

UnsupportedOperation – The operator is unsupported for the current type.

class jsonlogic.json_schema.types.NumberType
property name: str

The verbose name of the type to be used in diagnostic messages.

binary_op(other: JSONSchemaType, op: BinaryOp) JSONSchemaType

Get the resulting type of the binary operation with the other provided type.

Parameters:
  • other – The right hand operand of the operation.

  • op – The string representation of the operator.

Returns:

The return type of the operation.

Raises:

UnsupportedOperation – The operator is unsupported for the operands

unary_op(op: UnaryOp) JSONSchemaType

Get the resulting type of the unary operation.

Parameters:

op – The string representation of the operator.

Returns:

The return type of the operation.

Raises:

UnsupportedOperation – The operator is unsupported for the current type.

class jsonlogic.json_schema.types.IntegerType
property name: str

The verbose name of the type to be used in diagnostic messages.

binary_op(other: JSONSchemaType, op: BinaryOp) JSONSchemaType

Get the resulting type of the binary operation with the other provided type.

Parameters:
  • other – The right hand operand of the operation.

  • op – The string representation of the operator.

Returns:

The return type of the operation.

Raises:

UnsupportedOperation – The operator is unsupported for the operands

unary_op(op: UnaryOp) JSONSchemaType

Get the resulting type of the unary operation.

Parameters:

op – The string representation of the operator.

Returns:

The return type of the operation.

Raises:

UnsupportedOperation – The operator is unsupported for the current type.

class jsonlogic.json_schema.types.StringType
property name: str

The verbose name of the type to be used in diagnostic messages.

binary_op(other: JSONSchemaType, op: BinaryOp) NoReturn

Get the resulting type of the binary operation with the other provided type.

Parameters:
  • other – The right hand operand of the operation.

  • op – The string representation of the operator.

Returns:

The return type of the operation.

Raises:

UnsupportedOperation – The operator is unsupported for the operands

unary_op(op: UnaryOp) JSONSchemaType

Get the resulting type of the unary operation.

Parameters:

op – The string representation of the operator.

Returns:

The return type of the operation.

Raises:

UnsupportedOperation – The operator is unsupported for the current type.

class jsonlogic.json_schema.types.DatetimeType
property name: str

The verbose name of the type to be used in diagnostic messages.

binary_op(other: JSONSchemaType, op: BinaryOp) JSONSchemaType

Get the resulting type of the binary operation with the other provided type.

Parameters:
  • other – The right hand operand of the operation.

  • op – The string representation of the operator.

Returns:

The return type of the operation.

Raises:

UnsupportedOperation – The operator is unsupported for the operands

unary_op(op: UnaryOp) NoReturn

Get the resulting type of the unary operation.

Parameters:

op – The string representation of the operator.

Returns:

The return type of the operation.

Raises:

UnsupportedOperation – The operator is unsupported for the current type.

class jsonlogic.json_schema.types.DateType
property name: str

The verbose name of the type to be used in diagnostic messages.

binary_op(other: JSONSchemaType, op: BinaryOp) JSONSchemaType

Get the resulting type of the binary operation with the other provided type.

Parameters:
  • other – The right hand operand of the operation.

  • op – The string representation of the operator.

Returns:

The return type of the operation.

Raises:

UnsupportedOperation – The operator is unsupported for the operands

unary_op(op: UnaryOp) NoReturn

Get the resulting type of the unary operation.

Parameters:

op – The string representation of the operator.

Returns:

The return type of the operation.

Raises:

UnsupportedOperation – The operator is unsupported for the current type.

class jsonlogic.json_schema.types.DurationType
property name: str

The verbose name of the type to be used in diagnostic messages.

binary_op(other: JSONSchemaType, op: BinaryOp) JSONSchemaType

Get the resulting type of the binary operation with the other provided type.

Parameters:
  • other – The right hand operand of the operation.

  • op – The string representation of the operator.

Returns:

The return type of the operation.

Raises:

UnsupportedOperation – The operator is unsupported for the operands

unary_op(op: UnaryOp) JSONSchemaType

Get the resulting type of the unary operation.

Parameters:

op – The string representation of the operator.

Returns:

The return type of the operation.

Raises:

UnsupportedOperation – The operator is unsupported for the current type.

class jsonlogic.json_schema.types.NullType
property name: str

The verbose name of the type to be used in diagnostic messages.

binary_op(other: JSONSchemaType, op: BinaryOp) NoReturn

Get the resulting type of the binary operation with the other provided type.

Parameters:
  • other – The right hand operand of the operation.

  • op – The string representation of the operator.

Returns:

The return type of the operation.

Raises:

UnsupportedOperation – The operator is unsupported for the operands

unary_op(op: UnaryOp) JSONSchemaType

Get the resulting type of the unary operation.

Parameters:

op – The string representation of the operator.

Returns:

The return type of the operation.

Raises:

UnsupportedOperation – The operator is unsupported for the current type.