Ejemplo n.º 1
0
 /**
  * @param null $field
  * @param Validation $validation
  * @return bool
  */
 public function validate($field = null, Validation $validation)
 {
     if (!$this->getDataCollection()->has($field)) {
         $message = $this->getOption('message', $this->getDefaultMessage());
         $validation->appendMessage(new Message($field, $message, $this->getOptions() + ['field' => $field]));
         return false;
     }
     return true;
 }
Ejemplo n.º 2
0
 /**
  * @param null $field
  * @param Validation $validation
  * @return bool
  */
 public function validate($field = null, Validation $validation)
 {
     if (!is_numeric($this->getValue($field))) {
         $message = $this->getOption('message', $this->getDefaultMessage());
         $validation->appendMessage(new Message($field, $message, $this->getOptions() + ['field' => $field]));
         return false;
     }
     return true;
 }
Ejemplo n.º 3
0
 /**
  * @param null $field
  * @param Validation $validation
  * @return bool
  */
 public function validate($field = null, Validation $validation)
 {
     $value = $this->getValue($field);
     if (!ctype_xdigit($value)) {
         $message = $this->getOption('message', $this->getDefaultMessage());
         $validation->appendMessage(new Message($field, $message, $this->getOptions() + ['field' => $field]));
         return false;
     }
     return true;
 }
Ejemplo n.º 4
0
 /**
  * @param null $field
  * @param Validation $validation
  * @return bool
  */
 public function validate($field = null, Validation $validation)
 {
     $value = $this->getValue($field);
     $accepted = $this->getOption('accepted', null);
     if ($value !== $accepted) {
         $message = $this->getOption('message', $this->getDefaultMessage());
         $replacements = $this->getOptions() + ['field' => $field, 'accepted' => $accepted];
         $validation->appendMessage(new Message($field, $message, $replacements));
         return false;
     }
     return true;
 }
Ejemplo n.º 5
0
 /**
  * @param null $field
  * @param Validation $validation
  * @return bool
  */
 public function validate($field = null, Validation $validation)
 {
     $value = $this->getValue($field);
     $min = $this->getOption('min', 1);
     $max = $this->getOption('max', PHP_INT_MAX - 1);
     if (mb_strlen($value) > $max || mb_strlen($value) < $min) {
         $message = $this->getOption('message', $this->getDefaultMessage());
         $validation->appendMessage(new Message($field, $message, $this->getOptions() + ['field' => $field]));
         return false;
     }
     return true;
 }
Ejemplo n.º 6
0
 /**
  * @param null $field
  * @param Validation $validation
  * @return bool
  */
 public function validate($field = null, Validation $validation)
 {
     $value = $this->getValue($field);
     $comparableField = $this->getOption('comparable', null);
     $comparable = $this->getDataCollection()->get($comparableField, null);
     if (null === $comparable || $value !== $comparable) {
         $message = $this->getOption('message', $this->getDefaultMessage());
         $replacements = ['field' => $field, 'comparable' => $comparableField];
         $validation->appendMessage(new Message($field, $message, $replacements));
         return false;
     }
     return true;
 }
Ejemplo n.º 7
0
 /**
  * @param null $field
  * @param Validation $validation
  * @return bool
  */
 public function validate($field = null, Validation $validation)
 {
     $set = $this->getOption('set', []);
     $set = is_array($set) ? $set : [$set];
     $value = $this->getValue($field);
     if (!in_array($value, $set)) {
         $message = $this->getOption('message', $this->getDefaultMessage());
         $replacements = ['field' => $field, 'set' => implode(', ', $set)];
         $validation->appendMessage(new Message($field, $message, $replacements));
         return false;
     }
     return true;
 }