public static function ReflectImageEffect::validateSize in ImageCache Reflect 8
Validates to ensure a percentage or positive integer.
@todo Use drupal 8 validation API? Symfony has regex validator.
File
- lib/
Drupal/ imagecache_reflect/ Plugin/ ImageEffect/ ReflectImageEffect.php, line 129 - Contains \Drupal\imagecache_reflect\Plugin\ImageEffect\ReflectImageEffect.
Class
- ReflectImageEffect
- Creates a reflection-like effect on an image resource.
Namespace
Drupal\imagecache_reflect\Plugin\ImageEffectCode
public static function validateSize(array $element, array &$form_state) {
if (!preg_match('/^([0-9]{1,2}|100)%$|^([0-9]{1,3})$/', $element['#value'])) {
\Drupal::formBuilder()
->setError($element, \t('!name must be a percentage from 1 to 100 or a positive integer 3 digits or less.', array(
'!name' => $element['#title'],
)));
}
}