Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * Required Validator
- */
- class iPhorm_Validator_Required extends iPhorm_Validator_Abstract
- {
- protected $_message = 'This field is required';
- public function __construct($options)
- {
- if (isset($options['message'])) {
- $this->_message = $options['message'];
- }
- }
- /**
- * Checks whether the given value is not empty. Also sets
- * the error message if value is empty.
- *
- * @param $value The value to check
- * @return boolean True if valid false otherwise
- */
- public function isValid($value)
- {
- $valid = true;
- if ($value === null || $value === '') {
- $this->addMessage($this->_message);
- $valid = false;
- }
- return $valid;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement