I'm trying to devise a scheme for validating form fields. I've decided you can pass in a list of validators to each field like,
Field(validators=[email_validator, required_validator])
But then I thought, what if you wanted to or
the validators together, rather than and
ing them? For example, a field that accepts either a Canadian postal code, or a US zip code. Sure, I could just create a new validator that could accept either, but it would be neat if I could come up of a way of allowing the user to choose.
Is there maybe some way that I could manipulate the bitwise operators?
Field(validators = required&(postal_code|zip_code))
Or am I just making things way too complicated and shooting myself in the foot?