Validation annotations for dlang structs
import dutils.validation.constraints : ValidateRequired, ValidateEmail
struct Email {
@ValidateRequired()
@ValidateEmail()
string to;
@ValidateRequired()
@ValidateEmail()
string from;
@ValidateMinimumLength(3)
@ValidateMaximumLength(100)
string subject;
string body;
}
auto email = Email("badto.address", "[email protected]", "no", "some body");
validate(email); // throws an instance of ValidationErrors
- Support for nested structs and arrays