Features: Validation
Validation can be performed at the server side by overriding the Validate
method.
When validation is unsuccessful, you can add a ValidationError
to the list with an appropriate message, which will be shown at the client as a message box.
[DisplayName("Number 1")]
[Description("This number must be greater than Number 2.")]
public int Number1 { get; set; } = 10;
[DisplayName("Number 2")]
[Description("Try setting this to a value >= Number 1 and save.")]
public int Number2 { get; set; } = 5;
protected override void Validate(IEditObjectContainer container, ValidationErrorList errorList)
{
if (this.Number1 <= this.Number2)
{
ValidationError error = this.CreateValidationError(container, nameof(this.Number1), "Number 1 must be greater than Number 2!");
errorList.Add(error);
}
}