def validate_phone(target, value, oldvalue, initiator):
    """Strip non-numeric characters from a phone number"""
return re.sub('(?![0-9])', '', value)
listen(UserContact.phone, 'set', validate_phone, retval=True)
Flask Python Model Validation