String MinLength and MaxLength validation don't work (asp.net mvc)

前端 未结 5 2011
慢半拍i
慢半拍i 2020-12-12 20:27

I have this class

using System.ComponentModel.DataAnnotations;
using Argussoft.BI.DAL.Domain.Users;

namespace Argussoft.BI.DAL.DTOs.UserDTOs
{
    public cl         


        
5条回答
  •  一生所求
    2020-12-12 21:05

        [StringLength(16, ErrorMessageResourceName= "PasswordMustBeBetweenMinAndMaxCharacters", ErrorMessageResourceType = typeof(Resources.Resource), MinimumLength = 6)]
        [Display(Name = "Password", ResourceType = typeof(Resources.Resource))]
        public string Password { get; set; }
    

    Save resource like this

    "ThePasswordMustBeAtLeastCharactersLong" | "The password must be {1} at least {2} characters long"
    

提交回复
热议问题