VSB
VSB

Reputation: 10415

ASP.Net MVC Models: MinLength Limit only in StringLength validation

I'm going to create a property for my Model which got minLength = 6 but no limit for its maximum.

Using below syntax, Visual Studio says there are no overloads for below syntax and I should put MaxmimumLength as first parameter. So are there any MAX_LENGTH constants or such thing to put as first parameter?

    [StringLength(MinimumLength = 6)]
    public string Name { get; set; }

Upvotes: 1

Views: 584

Answers (1)

CodingGorilla
CodingGorilla

Reputation: 19862

Try this:

[StringLength(Int32.MaxValue, MinimumLength = 6)]
public string Name { get; set; }

Upvotes: 3

Related Questions