c# - model validation rule starts with and ends with -


i need add validator property of class enforces following:

must start "tr" or "we" , end 3-4 digit number. have additional validating rules such length , required can't figure out how enforce 1 outlined above. suspect have regex in someway i'm not sure of syntax.

public string tree { get; set; } 

try following:

[regularexpression("^(tr|we)[a-z,a-z]*[0-9]{3,4}$")] public string tree { get; set; } 

you can read docs examples/more info: https://msdn.microsoft.com/en-us/library/system.componentmodel.dataannotations.regularexpressionattribute(v=vs.110).aspx


Comments

Popular posts from this blog

ZeroMQ on Windows, with Qt Creator -

unity3d - Unity SceneManager.LoadScene quits application -

python - Error while using APScheduler: 'NoneType' object has no attribute 'now' -