@@ -1499,18 +1499,18 @@ def __call__(self, __input_value: Any, __info: ModelFieldValidationInfo) -> Any:
1499
1499
...
1500
1500
1501
1501
1502
- class FieldValidatorCallbackSchema (TypedDict ):
1502
+ class FieldValidatorFunctionSchema (TypedDict ):
1503
1503
type : Literal ['field' ]
1504
- call : FieldValidatorCallback
1504
+ function : FieldValidatorCallback
1505
1505
1506
1506
1507
- class GeneralValidatorCallbackSchema (TypedDict ):
1507
+ class GeneralValidatorFunctionSchema (TypedDict ):
1508
1508
type : Literal ['general' ]
1509
- call : GeneralValidatorCallback
1509
+ function : GeneralValidatorCallback
1510
1510
1511
1511
1512
- class CallbackSchema (TypedDict , total = False ):
1513
- function : Required [Union [FieldValidatorCallbackSchema , GeneralValidatorCallbackSchema ]]
1512
+ class FunctionSchema (TypedDict , total = False ):
1513
+ function : Required [Union [FieldValidatorFunctionSchema , GeneralValidatorFunctionSchema ]]
1514
1514
type : Required [Literal ['function' ]]
1515
1515
mode : Required [Literal ['before' , 'after' ]]
1516
1516
schema : Required [CoreSchema ]
@@ -1519,14 +1519,14 @@ class CallbackSchema(TypedDict, total=False):
1519
1519
serialization : SerSchema
1520
1520
1521
1521
1522
- def field_before_validation_callback (
1522
+ def field_before_validation_function (
1523
1523
function : FieldValidatorCallback ,
1524
1524
schema : CoreSchema ,
1525
1525
* ,
1526
1526
ref : str | None = None ,
1527
1527
metadata : Any = None ,
1528
1528
serialization : SerSchema | None = None ,
1529
- ) -> CallbackSchema :
1529
+ ) -> FunctionSchema :
1530
1530
"""
1531
1531
Returns a schema that calls a validator function before validating
1532
1532
the provided **model field** schema, e.g.:
@@ -1539,7 +1539,7 @@ def fn(v: bytes, info: core_schema.ModelFieldValidationInfo) -> str:
1539
1539
assert info.field_name is not None
1540
1540
return v.decode() + 'world'
1541
1541
1542
- func_schema = core_schema.field_before_validation_callback (function=fn, schema=core_schema.str_schema())
1542
+ func_schema = core_schema.field_before_validation_function (function=fn, schema=core_schema.str_schema())
1543
1543
schema = core_schema.typed_dict_schema(
1544
1544
{'a': core_schema.typed_dict_field(func_schema)}
1545
1545
)
@@ -1558,22 +1558,22 @@ def fn(v: bytes, info: core_schema.ModelFieldValidationInfo) -> str:
1558
1558
return dict_not_none (
1559
1559
type = 'function' ,
1560
1560
mode = 'before' ,
1561
- function = {'type' : 'field' , 'call ' : function },
1561
+ function = {'type' : 'field' , 'function ' : function },
1562
1562
schema = schema ,
1563
1563
ref = ref ,
1564
1564
metadata = metadata ,
1565
1565
serialization = serialization ,
1566
1566
)
1567
1567
1568
1568
1569
- def general_before_validation_callback (
1569
+ def general_before_validation_function (
1570
1570
function : GeneralValidatorCallback ,
1571
1571
schema : CoreSchema ,
1572
1572
* ,
1573
1573
ref : str | None = None ,
1574
1574
metadata : Any = None ,
1575
1575
serialization : SerSchema | None = None ,
1576
- ) -> CallbackSchema :
1576
+ ) -> FunctionSchema :
1577
1577
"""
1578
1578
Returns a schema that calls a validator function before validating the provided schema, e.g.:
1579
1579
@@ -1586,7 +1586,7 @@ def fn(v: Any, info: core_schema.ValidationInfo) -> str:
1586
1586
assert 'hello' in v_str
1587
1587
return v_str + 'world'
1588
1588
1589
- schema = core_schema.general_before_validation_callback (function=fn, schema=core_schema.str_schema())
1589
+ schema = core_schema.general_before_validation_function (function=fn, schema=core_schema.str_schema())
1590
1590
v = SchemaValidator(schema)
1591
1591
assert v.validate_python(b'hello ') == "b'hello 'world"
1592
1592
```
@@ -1601,22 +1601,22 @@ def fn(v: Any, info: core_schema.ValidationInfo) -> str:
1601
1601
return dict_not_none (
1602
1602
type = 'function' ,
1603
1603
mode = 'before' ,
1604
- function = {'type' : 'general' , 'call ' : function },
1604
+ function = {'type' : 'general' , 'function ' : function },
1605
1605
schema = schema ,
1606
1606
ref = ref ,
1607
1607
metadata = metadata ,
1608
1608
serialization = serialization ,
1609
1609
)
1610
1610
1611
1611
1612
- def field_after_validation_callback (
1612
+ def field_after_validation_function (
1613
1613
function : FieldValidatorCallback ,
1614
1614
schema : CoreSchema ,
1615
1615
* ,
1616
1616
ref : str | None = None ,
1617
1617
metadata : Any = None ,
1618
1618
serialization : SerSchema | None = None ,
1619
- ) -> CallbackSchema :
1619
+ ) -> FunctionSchema :
1620
1620
"""
1621
1621
Returns a schema that calls a validator function after validating
1622
1622
the provided **model field** schema, e.g.:
@@ -1629,7 +1629,7 @@ def fn(v: str, info: core_schema.ModelFieldValidationInfo) -> str:
1629
1629
assert info.field_name is not None
1630
1630
return v + 'world'
1631
1631
1632
- func_schema = core_schema.field_after_validation_callback (function=fn, schema=core_schema.str_schema())
1632
+ func_schema = core_schema.field_after_validation_function (function=fn, schema=core_schema.str_schema())
1633
1633
schema = core_schema.typed_dict_schema(
1634
1634
{'a': core_schema.typed_dict_field(func_schema)}
1635
1635
)
@@ -1648,22 +1648,22 @@ def fn(v: str, info: core_schema.ModelFieldValidationInfo) -> str:
1648
1648
return dict_not_none (
1649
1649
type = 'function' ,
1650
1650
mode = 'after' ,
1651
- function = {'type' : 'field' , 'call ' : function },
1651
+ function = {'type' : 'field' , 'function ' : function },
1652
1652
schema = schema ,
1653
1653
ref = ref ,
1654
1654
metadata = metadata ,
1655
1655
serialization = serialization ,
1656
1656
)
1657
1657
1658
1658
1659
- def general_after_validation_callback (
1659
+ def general_after_validation_function (
1660
1660
function : GeneralValidatorCallback ,
1661
1661
schema : CoreSchema ,
1662
1662
* ,
1663
1663
ref : str | None = None ,
1664
1664
metadata : Any = None ,
1665
1665
serialization : SerSchema | None = None ,
1666
- ) -> CallbackSchema :
1666
+ ) -> FunctionSchema :
1667
1667
"""
1668
1668
Returns a schema that calls a validator function after validating the provided schema, e.g.:
1669
1669
@@ -1674,7 +1674,7 @@ def fn(v: str, info: core_schema.ValidationInfo) -> str:
1674
1674
assert 'hello' in v
1675
1675
return v + 'world'
1676
1676
1677
- schema = core_schema.general_after_validation_callback (schema=core_schema.str_schema(), function=fn)
1677
+ schema = core_schema.general_after_validation_function (schema=core_schema.str_schema(), function=fn)
1678
1678
v = SchemaValidator(schema)
1679
1679
assert v.validate_python('hello ') == 'hello world'
1680
1680
```
@@ -1689,7 +1689,7 @@ def fn(v: str, info: core_schema.ValidationInfo) -> str:
1689
1689
return dict_not_none (
1690
1690
type = 'function' ,
1691
1691
mode = 'after' ,
1692
- function = {'type' : 'general' , 'call ' : function },
1692
+ function = {'type' : 'general' , 'function ' : function },
1693
1693
schema = schema ,
1694
1694
ref = ref ,
1695
1695
metadata = metadata ,
@@ -1716,18 +1716,18 @@ def __call__(
1716
1716
...
1717
1717
1718
1718
1719
- class FieldWrapValidatorCallbackSchema (TypedDict ):
1719
+ class FieldWrapValidatorFunctionSchema (TypedDict ):
1720
1720
type : Literal ['field' ]
1721
- call : FieldWrapValidatorCallback
1721
+ function : FieldWrapValidatorCallback
1722
1722
1723
1723
1724
- class GeneralWrapValidatorCallbackSchema (TypedDict ):
1724
+ class GeneralWrapValidatorFunctionSchema (TypedDict ):
1725
1725
type : Literal ['general' ]
1726
- call : GeneralWrapValidatorCallback
1726
+ function : GeneralWrapValidatorCallback
1727
1727
1728
1728
1729
- class WrapCallbackSchema (TypedDict , total = False ):
1730
- function : Required [Union [GeneralWrapValidatorCallbackSchema , FieldWrapValidatorCallbackSchema ]]
1729
+ class WrapFunctionSchema (TypedDict , total = False ):
1730
+ function : Required [Union [GeneralWrapValidatorFunctionSchema , FieldWrapValidatorFunctionSchema ]]
1731
1731
type : Required [Literal ['function' ]]
1732
1732
mode : Required [Literal ['wrap' ]]
1733
1733
schema : Required [CoreSchema ]
@@ -1736,14 +1736,14 @@ class WrapCallbackSchema(TypedDict, total=False):
1736
1736
serialization : SerSchema
1737
1737
1738
1738
1739
- def general_wrap_validation_callback (
1739
+ def general_wrap_validation_function (
1740
1740
function : GeneralWrapValidatorCallback ,
1741
1741
schema : CoreSchema ,
1742
1742
* ,
1743
1743
ref : str | None = None ,
1744
1744
metadata : Any = None ,
1745
1745
serialization : SerSchema | None = None ,
1746
- ) -> WrapCallbackSchema :
1746
+ ) -> WrapFunctionSchema :
1747
1747
"""
1748
1748
Returns a schema which calls a function with a `validator` callable argument which can
1749
1749
optionally be used to call inner validation with the function logic, this is much like the
@@ -1755,7 +1755,7 @@ def general_wrap_validation_callback(
1755
1755
def fn(v: str, validator: core_schema.CallableValidator, info: core_schema.ValidationInfo) -> str:
1756
1756
return validator(input_value=v) + 'world'
1757
1757
1758
- schema = core_schema.general_wrap_validation_callback (function=fn, schema=core_schema.str_schema())
1758
+ schema = core_schema.general_wrap_validation_function (function=fn, schema=core_schema.str_schema())
1759
1759
v = SchemaValidator(schema)
1760
1760
assert v.validate_python('hello ') == 'hello world'
1761
1761
```
@@ -1770,22 +1770,22 @@ def fn(v: str, validator: core_schema.CallableValidator, info: core_schema.Valid
1770
1770
return dict_not_none (
1771
1771
type = 'function' ,
1772
1772
mode = 'wrap' ,
1773
- function = {'type' : 'general' , 'call ' : function },
1773
+ function = {'type' : 'general' , 'function ' : function },
1774
1774
schema = schema ,
1775
1775
ref = ref ,
1776
1776
metadata = metadata ,
1777
1777
serialization = serialization ,
1778
1778
)
1779
1779
1780
1780
1781
- def field_wrap_validation_callback (
1781
+ def field_wrap_validation_function (
1782
1782
function : FieldWrapValidatorCallback ,
1783
1783
schema : CoreSchema ,
1784
1784
* ,
1785
1785
ref : str | None = None ,
1786
1786
metadata : Any = None ,
1787
1787
serialization : SerSchema | None = None ,
1788
- ) -> WrapCallbackSchema :
1788
+ ) -> WrapFunctionSchema :
1789
1789
"""
1790
1790
Returns a schema applicable to **fields**
1791
1791
which calls a function with a `validator` callable argument which can
@@ -1800,7 +1800,7 @@ def fn(v: bytes, validator: core_schema.CallableValidator, info: core_schema.Mod
1800
1800
assert info.field_name is not None
1801
1801
return validator(v) + 'world'
1802
1802
1803
- func_schema = core_schema.field_wrap_validation_callback (function=fn, schema=core_schema.str_schema())
1803
+ func_schema = core_schema.field_wrap_validation_function (function=fn, schema=core_schema.str_schema())
1804
1804
schema = core_schema.typed_dict_schema(
1805
1805
{'a': core_schema.typed_dict_field(func_schema)}
1806
1806
)
@@ -1819,30 +1819,30 @@ def fn(v: bytes, validator: core_schema.CallableValidator, info: core_schema.Mod
1819
1819
return dict_not_none (
1820
1820
type = 'function' ,
1821
1821
mode = 'wrap' ,
1822
- function = {'type' : 'field' , 'call ' : function },
1822
+ function = {'type' : 'field' , 'function ' : function },
1823
1823
schema = schema ,
1824
1824
ref = ref ,
1825
1825
metadata = metadata ,
1826
1826
serialization = serialization ,
1827
1827
)
1828
1828
1829
1829
1830
- class PlainCallbackSchema (TypedDict , total = False ):
1830
+ class PlainFunctionSchema (TypedDict , total = False ):
1831
1831
type : Required [Literal ['function' ]]
1832
1832
mode : Required [Literal ['plain' ]]
1833
- function : Required [Union [FieldValidatorCallbackSchema , GeneralValidatorCallbackSchema ]]
1833
+ function : Required [Union [FieldValidatorFunctionSchema , GeneralValidatorFunctionSchema ]]
1834
1834
ref : str
1835
1835
metadata : Any
1836
1836
serialization : SerSchema
1837
1837
1838
1838
1839
- def general_plain_validation_callback (
1839
+ def general_plain_validation_function (
1840
1840
function : GeneralValidatorCallback ,
1841
1841
* ,
1842
1842
ref : str | None = None ,
1843
1843
metadata : Any = None ,
1844
1844
serialization : SerSchema | None = None ,
1845
- ) -> PlainCallbackSchema :
1845
+ ) -> PlainFunctionSchema :
1846
1846
"""
1847
1847
Returns a schema that uses the provided function for validation, e.g.:
1848
1848
@@ -1853,7 +1853,7 @@ def fn(v: str, info: core_schema.ValidationInfo) -> str:
1853
1853
assert 'hello' in v
1854
1854
return v + 'world'
1855
1855
1856
- schema = core_schema.general_plain_validation_callback (function=fn)
1856
+ schema = core_schema.general_plain_validation_function (function=fn)
1857
1857
v = SchemaValidator(schema)
1858
1858
assert v.validate_python("hello ") == 'hello world'
1859
1859
```
@@ -1867,20 +1867,20 @@ def fn(v: str, info: core_schema.ValidationInfo) -> str:
1867
1867
return dict_not_none (
1868
1868
type = 'function' ,
1869
1869
mode = 'plain' ,
1870
- function = {'type' : 'general' , 'call ' : function },
1870
+ function = {'type' : 'general' , 'function ' : function },
1871
1871
ref = ref ,
1872
1872
metadata = metadata ,
1873
1873
serialization = serialization ,
1874
1874
)
1875
1875
1876
1876
1877
- def field_plain_validation_callback (
1877
+ def field_plain_validation_function (
1878
1878
function : FieldValidatorCallback ,
1879
1879
* ,
1880
1880
ref : str | None = None ,
1881
1881
metadata : Any = None ,
1882
1882
serialization : SerSchema | None = None ,
1883
- ) -> PlainCallbackSchema :
1883
+ ) -> PlainFunctionSchema :
1884
1884
"""
1885
1885
Returns a schema that uses the provided function for validation, e.g.:
1886
1886
@@ -1893,7 +1893,7 @@ def fn(v: Any, info: core_schema.ModelFieldValidationInfo) -> str:
1893
1893
assert info.field_name is not None
1894
1894
return str(v) + 'world'
1895
1895
1896
- func_schema = core_schema.field_plain_validation_callback (function=fn)
1896
+ func_schema = core_schema.field_plain_validation_function (function=fn)
1897
1897
schema = core_schema.typed_dict_schema(
1898
1898
{'a': core_schema.typed_dict_field(func_schema)}
1899
1899
)
@@ -1911,7 +1911,7 @@ def fn(v: Any, info: core_schema.ModelFieldValidationInfo) -> str:
1911
1911
return dict_not_none (
1912
1912
type = 'function' ,
1913
1913
mode = 'plain' ,
1914
- function = {'type' : 'field' , 'call ' : function },
1914
+ function = {'type' : 'field' , 'function ' : function },
1915
1915
ref = ref ,
1916
1916
metadata = metadata ,
1917
1917
serialization = serialization ,
@@ -2196,7 +2196,7 @@ def fn(v: str, info: core_schema.ValidationInfo) -> str:
2196
2196
assert 'hello' in v
2197
2197
return v + ' world'
2198
2198
2199
- fn_schema = core_schema.general_plain_validation_callback (function=fn)
2199
+ fn_schema = core_schema.general_plain_validation_function (function=fn)
2200
2200
schema = core_schema.chain_schema(fn_schema, fn_schema, fn_schema, core_schema.str_schema())
2201
2201
v = SchemaValidator(schema)
2202
2202
assert v.validate_python("hello") == 'hello world world world'
@@ -3068,9 +3068,9 @@ def definition_reference_schema(
3068
3068
FrozenSetSchema ,
3069
3069
GeneratorSchema ,
3070
3070
DictSchema ,
3071
- CallbackSchema ,
3072
- WrapCallbackSchema ,
3073
- PlainCallbackSchema ,
3071
+ FunctionSchema ,
3072
+ WrapFunctionSchema ,
3073
+ PlainFunctionSchema ,
3074
3074
WithDefaultSchema ,
3075
3075
NullableSchema ,
3076
3076
UnionSchema ,
0 commit comments