private static string ValidatorsCodeSnippet(MinLengthInfo info)
        {
            string result = string.Format(
                @"{{Validator :Validators.minLength({1}), ErrorCode: 'minlength', ErrorMessage: ""{0} has minimum length of {1} characters"" }},
                ",
                info.Property.Name,
                info.Length);

            return(result);
        }
Exemplo n.º 2
0
        public void GenerateCode(IConceptInfo conceptInfo, ICodeBuilder codeBuilder)
        {
            if (conceptInfo is MinLengthInfo)
            {
                MinLengthInfo info = (MinLengthInfo)conceptInfo;

                if (DataStructureCodeGenerator.IsTypeSupported(info.Property.DataStructure))
                {
                    codeBuilder.InsertCode(ImplementationCodeSnippet((MinLengthInfo)info), MvcPropertyHelper.AttributeTag, info.Property);
                }
            }
        }
Exemplo n.º 3
0
 private static string ImplementationCodeSnippet(MinLengthInfo info)
 {
     return(string.Format(@"[MinLength({0})]
 ", info.Length));
 }