Apply validation rules for Widget properties | Widget Properties | Validation Rules

pankaj saxean asked on March 15, 2023 08:28

Hi team,

Need to know how to apply validation rules on widget properties. Like suppose I'm using the [EditingComponent(TextInputComponent.IDENTIFIER, Label = "{$Atlas.QuoteWidget.Author$}", Order = 3, Tooltip = "{$Atlas.tooltip.QuoteAuthor$}")] into the widget properties and I need to validate that user only fill 50 character on the text box so, how I do that.

Can any one share the details.

Recent Answers


Not Applicable answered on March 27, 2023 17:50

You can set a DataAnnotation attribute on the widget properties. Something like:

    [MaxLength(50, ErrorMessage = "Text must not contain more than 50 characters")]
0 votesVote for this answer Mark as a Correct answer

pankaj saxean answered on March 28, 2023 05:04

Thanks Marcel Vriend, but in case only the message shown, I need to show the message with field name and the field comes from the localization. So in that case I create our own custom DataAnnotation attribute like:-

[MaxWordDataValidation(50, "Localization Key Name")] [EditingComponent(TextInputComponent.IDENTIFIER, Label = "{$Localization Key Name$}", Order = 3, Tooltip = "{$Localization Key Name$}")]

And its worked.

0 votesVote for this answer Mark as a Correct answer

Dmitry Bastron answered on March 28, 2023 09:45

Hi Pankaj,

According to the documentation here, you should be able to achieve this by applying MaxLength attribute on top of your editing component.

0 votesVote for this answer Mark as a Correct answer

pankaj saxean answered on March 28, 2023 11:40

Hi Dmitry,

But in case using the MaxLength the error massage content is static, what will do if you want to show message content dynamic like:

"Person Name" must not contain more than 50 characters

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.