Skip to content

Commit 01041e4

Browse files
committed
fix error for long int input
1 parent b09ec90 commit 01041e4

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/input/shared.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ pub fn int_as_bool<'a>(input: &'a impl Input<'a>, int: i64) -> ValResult<'a, boo
5454
pub fn str_as_int<'s, 'l>(input: &'s impl Input<'s>, str: &'l str) -> ValResult<'s, EitherInt<'s>> {
5555
let len = str.len();
5656
if len > 4300 {
57-
Err(ValError::new(ErrorType::IntParsing, input))
57+
Err(ValError::new(ErrorType::IntParsingSize, input))
5858
} else if let Some(int) = _parse_str(input, str, len) {
5959
Ok(int)
6060
} else if let Some(str_stripped) = strip_decimal_zeros(str) {

tests/validators/test_int.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -345,18 +345,18 @@ def test_too_long():
345345

346346
assert exc_info.value.errors(include_url=False) == [
347347
{
348-
'type': 'int_parsing',
348+
'type': 'int_parsing_size',
349349
'loc': (),
350-
'msg': 'Input should be a valid integer, unable to parse string as an integer',
350+
'msg': 'Unable to parse input string as an integer, exceed maximum size',
351351
'input': '1' * 4301,
352352
}
353353
]
354354
# insert_assert(repr(exc_info.value))
355355
assert repr(exc_info.value) == (
356356
"1 validation error for int\n"
357-
" Input should be a valid integer, unable to parse string as an integer "
358-
"[type=int_parsing, input_value='111111111111111111111111...11111111111111111111111', input_type=str]\n"
359-
f" For further information visit https://errors.pydantic.dev/{__version__}/v/int_parsing"
357+
" Unable to parse input string as an integer, exceed maximum size "
358+
"[type=int_parsing_size, input_value='111111111111111111111111...11111111111111111111111', input_type=str]\n"
359+
f" For further information visit https://errors.pydantic.dev/{__version__}/v/int_parsing_size"
360360
)
361361

362362

0 commit comments

Comments
 (0)