optional static method
Wraps validator so that empty input is considered valid.
Useful for optional fields that should still be validated when the user enters something.
Implementation
static Validator optional(Validator validator) {
return (value) {
if (value == null || value.trim().isEmpty) return null;
return validator(value);
};
}