I am developing a validation regex using System.ComponentModel.DataAnnotations
and RegularExpression
of asp.net mvc C #, in this regex it is necessary to validate time duration without limits in hours and the time must be greater than 00:00
, that is, values can be accepted from 00:01
respecting the limits of minutes (59) and seconds (59).
I was able to get up at: \d{1,}:[0-5][0-9]
04:00 -- true
00:01 -- true
00:23 -- true
00:04 -- true
04:00 -- true
01:00 -- true
23:00 -- true
21:00 -- true
1:00 -- true
00:61 -- false
00:00 --> problema
57:59 -- true
123:59 -- true
As this is a form, I am just validating a time and not a set of values, as follows:
Iwouldlikehelpwithdenyingthe00:00
valueinthisregex.AsitgetsinaRegularExpressioninDataAnnotations,orisboundinmy"Duration" model, I need to fit in just one validation:
[RegularExpression("^(\d{1,}:[0-5][0-9])$", ErrorMessageResourceName = "CampoObrigatorio")]
public string Duracao { get; set; }