ArcGIS Pro 3.7 API Reference Guide
ArcGIS.Desktop.Editing.Attributes Namespace / Attribute Class / AddValidate Method
an anonymous method
Example

In This Topic
    AddValidate Method
    In This Topic
    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
    Inspector.AddValidate
    // Adds a custom validation rule to the "Mineral" field of the specified feature layer.
    await QueuedTask.Run(() =>
    {
      var insp = new Inspector();
      insp.LoadSchema(featureLayer);
      var attrib = insp.Where(a => a.FieldName == "Mineral").First();
      attrib.AddValidate(() =>
      {
        if (attrib.CurrentValue.ToString() == "Salt")
          return [];
        else return [ArcGIS.Desktop.Editing.Attributes.Attribute.ValidationError.Create("Error", Severity.Low)];
      });
    });
    Requirements

    Target Platforms: Windows 11 Home, Pro, Enterprise (64 bit)

    ArcGIS Pro version: 3.0 or higher.
    See Also