iframe_consent-1.0.x-dev/src/Plugin/Validation/Constraint/IframeConsentDomainConstraint.php

src/Plugin/Validation/Constraint/IframeConsentDomainConstraint.php
<?php

declare(strict_types=1);

namespace Drupal\iframe_consent\Plugin\Validation\Constraint;

use Symfony\Component\Validator\Constraint;

/**
 * Provides a Domain constraint.
 *
 * @Constraint(
 *   id = "IframeConsentDomain",
 *   label = @Translation("Iframe consent Domain validation", context = "Validation"),
 *   type = "string",
 * )
 *
 * @DCG
 * To apply this constraint on third party field types. Implement
 * hook_field_info_alter() as follows.
 * @code
 * function iframe_consent_field_info_alter(array &$info): void {
 *   $info['FIELD_TYPE']['constraints']['IframeConsentDomain'] = [];
 * }
 * @endcode
 *
 * @see https://www.drupal.org/node/2015723
 */
final class IframeConsentDomainConstraint extends Constraint {

  /**
   * The message shown when the domain is empty.
   */
  public string $emptyMessage = 'The domain field cannot be empty.';

  /**
   * The message shown when the domain is not valid.
   */
  public string $httpsMessage = 'The domain %domain is not valid. Should be https or http.';

  /**
   * The message shown when the domain is not valid.
   */
  public string $formatMessage = 'The domain %domain is not valid. Should contain only the protocol and the host';

  /**
   * The message shown when the domain is not valid.
   */
  public string $duplicateMessage = 'The domain %domain is already defined in another entry.';

}

Главная | Обратная связь

drupal hosting | друпал хостинг | it patrol .inc