Customised Validation Message on ListItems Attribute

Vote:
 

I'm using ListItems attribute on IList which shows a validation message. 'The field Answers is invalid'

I want to show a customised message. How to do it?

[ListItems(2,int.MaxValue)]
public virtual IList<QuestionnaireAnswerBlock> Answers { get; set; }

#224893
Jun 29, 2020 6:19
Vote:
 
[ListItems(2, int.MaxValue, ErrorMessage="At least two items, please!")]
public virtual IList<QuestionnaireAnswerBlock> Answers { get; set; }

Or, if you want full control, you could create your own custom validation:

https://www.jondjones.com/learn-episerver-cms/episerver-developers-tutorials/episerver-content-areas/how-to-create-a-custom-content-area-validator-in-episerver/

#224897
Edited, Jun 29, 2020 7:40
Vote:
 
 [ListItems(2,6,ErrorMessage ="Minimum 2 and Maximum 6 columns are allowed")]

#224901
Jun 29, 2020 11:01
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.