Skip to content

Latest commit

 

History

History
34 lines (22 loc) · 859 Bytes

README.md

File metadata and controls

34 lines (22 loc) · 859 Bytes

validation

DUB Package Posix Build Status

Validation annotations for dlang structs

example

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

TODO

  • Support for nested structs and arrays