public InstanceValidationResultImpl getValidationResult(ViewEntity viewEntity, Validator.ValidationContext context)
      throws IllegalStateException {

    Map<String, ValidationResult> propertyResults = new HashMap<>();

    if (context.equals(Validator.ValidationContext.PRE_CREATE) ||
        context.equals(Validator.ValidationContext.PRE_UPDATE)) {

      // make sure that there is an instance property value defined
      // for each required view parameter
      Set<String> requiredParameterNames = new HashSet<>();
      for (ViewParameterEntity parameter : viewEntity.getParameters()) {
        if (parameter.isRequired()) {
          // Don't enforce 'required' validation for cluster config parameters since
          // the value will be obtained through cluster association, not user input
          if (parameter.getClusterConfig()== null) {
            requiredParameterNames.add(parameter.getName());
          }
        }
      }
      Map<String, String> propertyMap = getPropertyMap();
      for (Map.Entry<String, String> entry : propertyMap.entrySet()) {
        if (entry.getValue() != null) {
          requiredParameterNames.remove(entry.getKey());
        }
      }
      // required but missing instance properties...
      for (String requiredParameterName : requiredParameterNames) {
        propertyResults.put(requiredParameterName,
            new ValidationResultImpl(false,
                "No property values exist for the required parameter " + requiredParameterName + "."));
      }
    }

    ValidationResult instanceResult = null;
    Validator         validator     = viewEntity.getValidator();

    // if the view provides its own validator, run it
    if (validator != null) {
      instanceResult = validator.validateInstance(this, context);
      for ( String property : getPropertyMap().keySet()) {
        if (!propertyResults.containsKey(property)) {
          propertyResults.put(property,
              ValidationResultImpl.create(validator.validateProperty(property, this, context)));
        }
      }
    }
    return new InstanceValidationResultImpl(ValidationResultImpl.create(instanceResult), propertyResults);
  }
Get the validation the state of the instance.

@param viewEntity the view entity to which this instance will be bound
@param context the validation context

@return the instance validation result
ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ViewInstanceEntity.java