1: <?php
2:
3: /**
4: * Pry Framework
5: *
6: * LICENSE
7: *
8: * This source file is subject to the new BSD license that is bundled
9: * with this package in the file LICENSE.txt.
10: *
11: */
12:
13: namespace Pry\Form\Element;
14:
15: use Pry\Form\Error;
16:
17: /**
18: * Element Email. Permet de valider une adresse mail dans un champs text
19: *
20: * @category Pry
21: * @package Form
22: * @subpackage Form_Element
23: * @version 1.0.1
24: * @author Olivier ROGER <oroger.fr>
25: */
26: class Email extends Text
27: {
28:
29: /**
30: * Validation de contenu
31: *
32: * @param string $value
33: * @access public
34: * @return boolean
35: */
36: public function isValid($value)
37: {
38: if (parent::isValid($value))
39: {
40: if (\Pry\Util\Strings::isMail($value) || (!$this->required && empty($value)))
41: return true;
42: else
43: $this->errorMsg = Error::MAIL;
44: return false;
45: }
46: }
47:
48: }
49:
50: ?>