Reference: https://octobercms.com/docs/database/traits#dynamic-validation-rules
For conditional rules I know you can use
public function beforeValidate()
{
if (!$this->is_remote) {
$this->rules['latitude'] = 'required';
$this->rules['longitude'] = 'required';
}
}
I am experiencing issues using the trait and rules though. The error message is not showing up. All I get is an alert saying "error". My before validate method is also not being called. I am not sure what I am doing wrong.
class Job extends Model
{
use \October\Rain\Database\Traits\Validation;
/**
* @var array Validation rules
*/
public $rules = [
'title' => 'required',
];
public $customMessages = [
'title.required' => 'Job title is required!',
];