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

            return(result);
        }
Exemple #2
0
        public void GenerateCode(IConceptInfo conceptInfo, ICodeBuilder codeBuilder)
        {
            if (conceptInfo is MaxLengthInfo)
            {
                MaxLengthInfo info = (MaxLengthInfo)conceptInfo;

                if (DataStructureCodeGenerator.IsTypeSupported(info.Property.DataStructure))
                {
                    codeBuilder.InsertCode(ImplementationCodeSnippet(info), MvcPropertyHelper.AttributeTag, info.Property);
                }
            }
        }
Exemple #3
0
 private static string ImplementationCodeSnippet(MaxLengthInfo info)
 {
     return(string.Format(@"[MaxLength({0})]
 ", info.Length));
 }