Skip to content

Commit

Permalink
feat(FIS-8339): FLOAT checker should also accept intgers
Browse files Browse the repository at this point in the history
  • Loading branch information
pkyosx committed Oct 23, 2024
1 parent 35fe68e commit df1f22a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion data_spec_validator/spec/validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ class FloatValidator(BaseValidator):

@staticmethod
def validate(value, extra, data):
ok = type(value) is float
ok = type(value) is float or type(value) is int
info = '' if ok else TypeError(f'{repr(value)} is not a float')
return ok, info

Expand Down
5 changes: 4 additions & 1 deletion test/test_spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,10 @@ class FloatSpec:
ok_data = dict(float_field=3.0)
assert validate_data_spec(ok_data, FloatSpec)

nok_data = dict(float_field=3)
ok_data = dict(float_field=3)
assert validate_data_spec(ok_data, FloatSpec)

nok_data = dict(float_field='3.0')
assert is_something_error(TypeError, validate_data_spec, nok_data, FloatSpec)

def test_str(self):
Expand Down

0 comments on commit df1f22a

Please sign in to comment.