PluginProbe
Metricool – Social media and site statistics / trunk
Metricool – Social media and site statistics vtrunk
2.1.0 2.0.2 2.0.1 2.0.0 1.27 trunk
metricool / app / Support / Validation / Rules / EmailRule.php

EmailRule.php in Metricool – Social media and site statistics trunk, at app/Support/Validation/Rules/EmailRule.php

26 lines 670 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 declare(strict_types=1);
4
5 namespace Metricool\Support\Validation\Rules;
6
7 class EmailRule extends AbstractRule
8 {
9 /**
10 * Checks if the field contains a valid email address. Empty values pass,
11 * combine with the required or requiredIf rule when the field must be
12 * filled.
13 * @inheritDoc
14 */
15 public function validate(string $field, $value, array $data): void
16 {
17 if (!is_string($value) || !is_email($value)) {
18 $this->fail(sprintf(
19 /* translators: %s is the field name */
20 __('%s must be a valid email address.', 'metricool'),
21 $field
22 ));
23 }
24 }
25 }
26