Vogen
Vogen copied to clipboard
respect data annotations
[ValueObject(typeof(int))]
[System.ComponentModel.DataAnnotations.Range(2,100, Error = "Generate validator from this. Hm. Even compile time validator for well know annotations"]
public partial struct CustomerId {
}
From the existing attributes, these might be relevant (ordered descending by usefulness, IMO):
- RangeAttribute (only for numerics)
- RegularExpressionAttribute (only for strings)
- StringLengthAttribute (only for strings)
- MinLengthAttribute (only for strings)
- MaxLengthAttribute (only for strings)
- UrlAttribute (only for strings)
- EmailAddressAttribute (only for strings)
- PhoneAttribute (only for strings)
- FileExtensionsAttribute (only for strings)
- CreditCardAttribute (only for strings)
- CustomValidationAttribute (basically just overhead / an annotation for the existing validation method)
at least one example can be handy to provide patches for others:) Range is good target.