Linas
Linas

Reputation: 4408

Kohana image upload validation

I'm having problems with image validation, documentation as always doesn't help, so there is my simple validation to check if image was uploaded

    $validate = Validation::factory($_FILES)
                ->rule('file', array('Upload::not_empty'));

But this gives me error ErrorException [ Warning ]: call_user_func_array() expects parameter 1 to be a valid callback, array must have exactly two members

What could be causing this error?

Upvotes: 1

Views: 1276

Answers (1)

The Pixel Developer
The Pixel Developer

Reputation: 13430

The 2nd argument for rule is a PHP callback. So this would suffice because the not_empty method in the upload class is static:

rule('file', 'Upload::not_empty');

You only really need to do the array syntax when the method is not static:

rule('file', array($class, 'method'));

Upvotes: 2

Related Questions