Files
spa-api/system/validation/rules/exclusion_of.php

43 lines
782 B
PHP
Raw Normal View History

2011-06-21 20:11:17 -05:00
<?php namespace System\Validation\Rules;
use System\Validation\Nullable_Rule;
2011-06-21 20:11:17 -05:00
class Exclusion_Of extends Nullable_Rule {
2011-06-21 20:11:17 -05:00
/**
* The reserved values for the attribute.
*
* @var string
*/
public $reserved;
/**
* Evaluate the validity of an attribute.
*
* @param string $attribute
* @param array $attributes
* @return bool
2011-06-21 20:11:17 -05:00
*/
public function check($attribute, $attributes)
{
if ( ! is_null($nullable = parent::check($attribute, $attributes)))
2011-06-21 20:11:17 -05:00
{
return $nullable;
2011-06-21 20:11:17 -05:00
}
return ! in_array($attributes[$attribute], $this->reserved);
}
/**
* Set the reserved values for the attribute
*
* @param array $reserved
2011-06-21 20:11:17 -05:00
* @return Exclusion_Of
*/
public function from($reserved)
{
$this->reserved = $reserved;
return $this;
}
}