You are here

protected function AddressFormatConstraintValidator::addViolation in Address 8

File

src/Plugin/Validation/Constraint/AddressFormatConstraintValidator.php, line 30

Class

AddressFormatConstraintValidator
Validates the address format constraint.

Namespace

Drupal\address\Plugin\Validation\Constraint

Code

protected function addViolation($field, $message, $invalid_value, AddressFormat $address_format) {
  $labels = LabelHelper::getFieldLabels($address_format);
  $label = $labels[$field];
  $this->context
    ->buildViolation($message, [
    '@name' => $label,
  ])
    ->atPath(FieldHelper::getPropertyName($field))
    ->setInvalidValue($invalid_value)
    ->addViolation();
}