c# - Validation a string length : either X or Y, not between X and Y? -
i use validation framework :
[stringlength(10, minimumlength=5)] public string mystring{ get; set; }
this allows me specify mystring length must between 5 , 10 characters long.
now have check if string either 5 long, or 10 long. no other length allowed. i'm quite sure stringlength
attribute inadequate, how ? have extend validation framework , how ?
thx
if can (i'm not familiar validation library in question) can use regular expression.
the regular expression validate character, length 5 or 10, be:
^.{5}(.{5})?$
if have digits, can use:
^\d{5}(\d{5})?$
Comments
Post a Comment