enhanced validation, added mimes config array.

This commit is contained in:
Taylor Otwell
2011-06-27 17:33:07 -05:00
parent bd3d8f6347
commit d51be02dd2
19 changed files with 841 additions and 411 deletions

View File

@@ -1,8 +1,8 @@
<?php namespace System\Validation\Rules;
use System\Validation\Rule;
use System\Validation\Nullable_Rule;
class With_Callback extends Rule {
class With_Callback extends Nullable_Rule {
/**
* The callback that will be used to validate the attribute.
@@ -16,27 +16,27 @@ class With_Callback extends Rule {
*
* @param string $attribute
* @param array $attributes
* @return void
* @return bool
*/
public function check($attribute, $attributes)
{
if ( ! array_key_exists($attribute, $attributes))
{
return true;
}
if ( ! is_callable($this->callback))
{
throw new \Exception("The validation callback for the [$attribute] attribute is not callable.");
}
if ( ! is_null($nullable = parent::check($attribute, $attributes)))
{
return $nullable;
}
return call_user_func($this->callback, $attributes[$attribute]);
}
/**
* Set the validation callback.
*
* @param function $callback
* @param function $callback
* @return With_Callback
*/
public function using($callback)