Developer forum

Forum » Development » How to apply errormessage for itemfield validation

How to apply errormessage for itemfield validation

Lars Larsen
Reply

Hi,

I am creating an item through the API and want to apply a validation to the itemfields in my item. I can see that it's possible to apply two types of validation attributtes: "RegExAttributte" and "RequiredAttribute". But I can not see how to apply an errormessage to these types of validation or how to apply an errormessage if using the attributte "ValidateAttributte". Isn't this possible?

 

 


Replies

 
Tim Voronov
Reply

Hello Lars Larsen!
At this moment, there is no possibility to add an error message via attribute.

You can only add a validator like this:

        Dim field = New ItemField()
        field.Validators = New ValidatorMetadataCollection()

        Dim validator = New ValidatorMetadata()
        validator.TypeName = Extensibility.AddInManager.GetAssemblyQualifiedName(GetType(RequiredAttribute))
        validator.ErrorMessage = "This field is required"

        field.Validators.Add(validator)

 

 

 

 

 
Lars Larsen
Reply

Hi Tim

Thanks for your answer. When will it be possible?

 

 

You must be logged in to post in the forum