Merge pull request #132 from niteoweb/fix/password_format

Add support for `password` string format
This commit is contained in:
A 2019-05-17 10:28:07 +01:00 committed by GitHub
commit 391d664dac
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 0 deletions

View file

@ -42,6 +42,7 @@ class Schema(object):
STRING_FORMAT_CALLABLE_GETTER = {
SchemaFormat.NONE: Format(text_type, TypeValidator(text_type)),
SchemaFormat.PASSWORD: Format(text_type, TypeValidator(text_type)),
SchemaFormat.DATE: Format(
format_date, TypeValidator(date, exclude=datetime)),
SchemaFormat.DATETIME: Format(format_datetime, TypeValidator(datetime)),

View file

@ -66,6 +66,14 @@ class TestSchemaUnmarshal(object):
assert result == value
def test_string_format_password(self):
schema = Schema(SchemaType.STRING, schema_format=SchemaFormat.PASSWORD)
value = 'password'
result = schema.unmarshal(value)
assert result == 'password'
def test_string_float_invalid(self):
schema = Schema('string')
value = 1.23