Attribute Validation

Attribute validation will allow you to define valid values for a field. If the user enters an incorrect value, then an error will be displayed to encourage the user to change it.

If the validation script returns true, the attribute value is valid , if it returns false then the value is not valid and an error message is returned.

Adding a custom validation error message

// Validate that a Field attribute value is between 10 and 20.
//  - If the value is not valid return a custom error message.  
if( f < 10 || f > 20 ) {
  // value is valid
  return true;
} else {
  // value is not valid, so return a custom error message
  return "Value " + f + " is not allowed";
}

Feature Validation

Feature validation will allow you to add logic and business driven validation that runs once all attribute validation rules have been met.

If the validation script returns true, the feature is valid , if it returns false then the value is not valid and an error message is returned.

Adding a custom validation error message

/** Validate a geometry by checking it against some conditions:
 *
 * This script validates that a geometry does not overlap with too many wells.
 *
 * @return - Boolean (true/false)
 */

// Get the layer to check against.
var wells = MapLayer($map, "wells");

// Find wells which intersect the geometry of the feature.
var overLappingWells = Intersects(wells, Geometry($feature));

// Validate by returning true or false.
if (Count(overLappingWells) > 10) {
  return false;
}
return true;