ActiveRecord\Validations::validates_presence_of PHP Method

validates_presence_of() public method

class Person extends ActiveRecord\Model { static $validates_presence_of = array( array('first_name'), array('last_name') ); } Available options:
  • message: custom error message
  • allow_blank: allow blank strings
  • allow_null: allow null strings
public validates_presence_of ( array $attrs )
$attrs array Validation definition
    public function validates_presence_of($attrs)
    {
        $configuration = array_merge(self::$DEFAULT_VALIDATION_OPTIONS, array('message' => Errors::$DEFAULT_ERROR_MESSAGES['blank'], 'on' => 'save'));
        foreach ($attrs as $attr) {
            $options = array_merge($configuration, $attr);
            $this->record->add_on_blank($options[0], $options['message']);
        }
    }