ArcGIS Pro 2.7 API Reference Guide
AddValidate Method
Example 

ArcGIS.Desktop.Editing.Attributes Namespace > Attribute Class : AddValidate Method
an anonymous method
Add custom validation functions for this attribute. This method must be called on the MCT. Use QueuedTask.Run.
Syntax

Parameters

f
an anonymous method
Exceptions
ExceptionDescription
This method or property must be called within the lambda passed to QueuedTask.Run.
Example
var insp = new Inspector();
insp.LoadSchema(featLayer);
var attrib = insp.Where(a => a.FieldName == "Mineral").First();

attrib.AddValidate(() =>
{
  if (attrib.CurrentValue.ToString() == "Salt")
    return Enumerable.Empty<ArcGIS.Desktop.Editing.Attributes.Attribute.ValidationError>();
  else return new[] { ArcGIS.Desktop.Editing.Attributes.Attribute.ValidationError.Create("Error", ArcGIS.Desktop.Editing.Attributes.Severity.Low) };
});
Requirements

Target Platforms: Windows 10, Windows 8.1

See Also

Reference

Attribute Class
Attribute Members