While failing on empty strings is absolutely correct, it would be nice to have email fields to not fail on validation when they have been declared as required = False.
My proposal would be to extend upon the BaseField._validate method to check for whether the field is required, and test for whether it is either None or empty after a white space strip, and return early if either is the case.
The rationale of this is that it will save you a lot of extra code in your application where you have to (django that is)
if form.cleaned_data['email']:
document.email = form.cleaned...
While failing on empty strings is absolutely correct, it would be nice to have email fields to not fail on validation when they have been declared as required = False.
My proposal would be to extend upon the BaseField._validate method to check for whether the field is required, and test for whether it is either None or empty after a white space strip, and return early if either is the case.
The rationale of this is that it will save you a lot of extra code in your application where you have to (django that is)
if form.cleaned_data['email']: document.email = form.cleaned...
TIA!