Five New Optimizely Certifications are Here! Validate your expertise and advance your career with our latest certification exams. Click here to find out more
AI OnAI Off
Five New Optimizely Certifications are Here! Validate your expertise and advance your career with our latest certification exams. Click here to find out more
You can use System.ComponentModel.DataAnnotations.StringLengthAttribute for string properties. But for XhtmlString properties you would need to roll your own validator.
I've blogged on this a while ago, https://www.herlitz.io/2022/12/21/validate-optimizely-xhtmlstring-property-length/
It'll enable you to have a minimum amount of characters as well as a maximum amount.
[Display(Name = "MainContent")]
[Required]
[XhtmlStringLengthValidation(50, 500, CustomErrorMessage = "The Main content field must contain more than {0} characters but less than {1}.")]
public virtual XhtmlString MainContent{ get; set; }
It should as well only count text characters not including the markup.
Hi,
At the moment our client is experiencing an issue when translating content using a third party plugin, which says that "The field Title must be a string or array type with a maximum length of '50'"
Is there any Data Annotation that i could use on a XHTMLString/String or would i need to create my own Validation method?
Thanks!