Skip to content

Instantly share code, notes, and snippets.

@jtemporal
Created October 13, 2018 14:22
Show Gist options
  • Save jtemporal/f6d51d209641b32782959e1a351dd2b8 to your computer and use it in GitHub Desktop.
Save jtemporal/f6d51d209641b32782959e1a351dd2b8 to your computer and use it in GitHub Desktop.
from schematics.types import IntType
from schematics.exceptions import ValidationError
class SizedNumberType(IntType):
def validate_number(self, number):
sized = str(number)
if len(sized) != 2:
raise ValidationError("This number doesn't comply with the expected format size 2")
return number
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment