2011-06-21 20:11:17 -05:00
|
|
|
<?php namespace System\Validation\Rules;
|
|
|
|
|
|
2011-06-27 17:33:07 -05:00
|
|
|
use System\Validation\Nullable_Rule;
|
2011-06-21 20:11:17 -05:00
|
|
|
|
2011-06-27 17:33:07 -05:00
|
|
|
class Presence_Of extends Nullable_Rule {
|
2011-06-21 20:11:17 -05:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Evaluate the validity of an attribute.
|
|
|
|
|
*
|
|
|
|
|
* @param string $attribute
|
|
|
|
|
* @param array $attributes
|
2011-06-27 17:33:07 -05:00
|
|
|
* @return bool
|
2011-06-21 20:11:17 -05:00
|
|
|
*/
|
|
|
|
|
public function check($attribute, $attributes)
|
|
|
|
|
{
|
2011-06-27 17:33:07 -05:00
|
|
|
if ( ! is_null($nullable = parent::check($attribute, $attributes)))
|
2011-06-21 20:11:17 -05:00
|
|
|
{
|
2011-06-27 17:33:07 -05:00
|
|
|
return $nullable;
|
2011-06-21 20:11:17 -05:00
|
|
|
}
|
|
|
|
|
|
2011-06-27 17:33:07 -05:00
|
|
|
// ---------------------------------------------------------
|
|
|
|
|
// The Nullable_Rule check method essentially is a check for
|
|
|
|
|
// the presence of an attribute, so there is no further
|
|
|
|
|
// checking that needs to be done.
|
|
|
|
|
// ---------------------------------------------------------
|
2011-06-21 20:11:17 -05:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|