This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.

Vojta Svoboda
Vojta Svoboda

Hi everybody,

Where I have to register my own validator, when I want to also seed some data during plugin instalation? Now I'm getting error:

Method [validateSomething] does not exist. where something is my custom validation rule.

I'm registering validator at Plugin.php boot method like that:

public function boot() {
    Validator::resolver(function($translator, $data, $rules, $messages, $customAttributes) {
        return new CustomValidator($translator, $data, $rules, $messages, $customAttributes);
    });
}

When I seed database manually, everythings works fine, include validations. I tried to register validator directly at seeder, but didn't help.

Any ideas?

Last updated

Johnny D.
Johnny D.

A little too late, but I've just faced this today. That happens because of access restrictions from certain requests, including october:up/update artisan commands, which will result in boot and register initialization methods not being fired (see http://octobercms.com/docs/plugin/registration#elevated-plugin).

Just set elevated permissions on your plugin.php class and your data will be validated just fine:

/**
 * @var bool Plugin requires elevated permissions.
 */
public $elevated = true;

Hope it helps someone.

1-2 of 2

You cannot edit posts or make replies: the forum has moved to talk.octobercms.com.