You are here

protected function FieldValidationRuleBase::emptyAndMalformed in Field Validation 8

Helper method for empty and malformed inputs which must fail.

This helper method is used in validations where certain pattern exists, eg. IP or Phone numer.

Parameters

string $fieldName: Which field to validate.

\Drupal\Core\Entity\EntityInterface $entity: EntityInterface to validate.

\Drupal\field_validation\Entity\FieldValidationRuleSet $ruleSet: Check for ruleset specific constraint.

3 calls to FieldValidationRuleBase::emptyAndMalformed()
EmailFieldValidationRuleTest::testEmailRule in tests/src/Kernel/Plugin/FieldValidationRule/EmailFieldValidationRuleTest.php
Test EmailFieldValidationRule.
IpFieldValidationRuleTest::testMaloformedAndEmptyIp in tests/src/Kernel/Plugin/FieldValidationRule/IpFieldValidationRuleTest.php
Tests empty and malformed input.
PhoneFieldValidationRuleTest::testPhoneFieldMalformed in tests/src/Kernel/Plugin/FieldValidationRule/PhoneFieldValidationRuleTest.php
Tests malformed and empty phone input.

File

tests/src/Kernel/Plugin/FieldValidationRule/FieldValidationRuleBase.php, line 110

Class

FieldValidationRuleBase
FieldValidationRuleBase class.

Namespace

Drupal\Tests\field_validation\Kernel\Plugin\FieldValidationRule

Code

protected function emptyAndMalformed(string $fieldName, EntityInterface $entity, FieldValidationRuleSet $ruleSet) {
  $this
    ->assertConstraintFail($entity, $fieldName, ' ', $ruleSet);
  $this
    ->assertConstraintFail($entity, $fieldName, '192.::232:aspod:', $ruleSet);
}