You are here

class NifConstraint in Field NIF 8

Checks if field_nif value is valid.

Plugin annotation


@Constraint(
  id = "NifValue",
  label = @Translation("NIF/CIF/NIE number constraint", context = "Validation"),
)

Hierarchy

  • class \Drupal\field_nif\Plugin\Validation\Constraint\NifConstraint extends \Symfony\Component\Validator\Constraint

Expanded class hierarchy of NifConstraint

File

src/Plugin/Validation/Constraint/NifConstraint.php, line 15

Namespace

Drupal\field_nif\Plugin\Validation\Constraint
View source
class NifConstraint extends Constraint {

  /**
   * The default violation message.
   *
   * @var string
   */
  public $message = '@value is not a valid @document_type document number.';

  /**
   * The supported types.
   *
   * @var array
   */
  public $supportedTypes;

  /**
   * Gets the violation message.
   *
   * @return string
   */
  public function getMessage() {
    return $this->message;
  }

  /**
   * Gets the supported types as array.
   *
   * @return array
   */
  public function getSupportedTypes() {
    return $this->supportedTypes;
  }

  /**
   * {@inheritdoc}
   */
  public function validatedBy() {
    return '\\Drupal\\field_nif\\Plugin\\Validation\\Constraint\\NifValueValidator';
  }

}

Members

Namesort descending Modifiers Type Description Overrides
NifConstraint::$message public property The default violation message.
NifConstraint::$supportedTypes public property The supported types.
NifConstraint::getMessage public function Gets the violation message.
NifConstraint::getSupportedTypes public function Gets the supported types as array.
NifConstraint::validatedBy public function Returns the name of the class that validates this constraint.