Mvc\Model\Validator\Numericality

Class Phalcon\Mvc\Model\Validator\Numericality

extends abstract class Phalcon\Mvc\Model\Validator

implements Phalcon\Mvc\Model\ValidatorInterface

Allows to validate if a field has a valid numeric format

use Phalcon\Mvc\Model\Validator\Numericality as NumericalityValidator;

class Products extends Phalcon\Mvc\Model
{

  public function validation()
  {
      $this->validate(new NumericalityValidator(array(
          'field' => 'price'
      )));
      if ($this->validationHasFailed() == true) {
          return false;
      }
  }

}

Methods

public boolean validate登录查看完整内容