MCPcopy
hub / github.com/pydantic/pydantic / int_schema

Function int_schema

pydantic-core/python/pydantic_core/core_schema.py:644–689  ·  pydantic-core/python/pydantic_core/core_schema.py::int_schema

Returns a schema that matches a int value, e.g.: ```py from pydantic_core import SchemaValidator, core_schema schema = core_schema.int_schema(multiple_of=2, le=6, ge=2) v = SchemaValidator(schema) assert v.validate_python('4') == 4 ``` Args: multiple_of: T

(
    *,
    multiple_of: int | None = None,
    le: int | None = None,
    ge: int | None = None,
    lt: int | None = None,
    gt: int | None = None,
    strict: bool | None = None,
    ref: str | None = None,
    metadata: dict[str, Any] | None = None,
    serialization: SerSchema | None = None,
)

Source from the content-addressed store, hash-verified

642
643
644def int_schema(
645 *,
646 multiple_of: int | None = None,
647 le: int | None = None,
648 ge: int | None = None,
649 lt: int | None = None,
650 gt: int | None = None,
651 strict: bool | None = None,
652 ref: str | None = None,
653 metadata: dict[str, Any] | None = None,
654 serialization: SerSchema | None = None,
655) -> IntSchema:
656 class="st">"""
657 Returns a schema that matches a int value, e.g.:
658
659 ```py
660 from pydantic_core import SchemaValidator, core_schema
661
662 schema = core_schema.int_schema(multiple_of=2, le=6, ge=2)
663 v = SchemaValidator(schema)
664 assert v.validate_python(&class="cm">#x27;4') == 4
665 ```
666
667 Args:
668 multiple_of: The value must be a multiple of this number
669 le: The value must be less than or equal to this number
670 ge: The value must be greater than or equal to this number
671 lt: The value must be strictly less than this number
672 gt: The value must be strictly greater than this number
673 strict: Whether the value should be a int or a value that can be converted to a int
674 ref: optional unique identifier of the schema, used to reference the schema in other places
675 metadata: Any other information you want to include with the schema, not used by pydantic-core
676 serialization: Custom serialization schema
677 class="st">"""
678 return _dict_not_none(
679 type=&class="cm">#x27;int',
680 multiple_of=multiple_of,
681 le=le,
682 ge=ge,
683 lt=lt,
684 gt=gt,
685 strict=strict,
686 ref=ref,
687 metadata=metadata,
688 serialization=serialization,
689 )
690
691
692class FloatSchema(TypedDict, total=False):

Callers

nothing calls this directly

Calls 1

_dict_not_noneFunction · 0.85

Tested by

no test coverage detected