Created
January 4, 2016 10:33
-
-
Save vojtasvoboda/9a163b3fcc9b4780d701 to your computer and use it in GitHub Desktop.
Register custom model validator in OctoberCMS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Acme\Plugin\Models; | |
use Acme\Plugin\Validators\ExtendedValidator; | |
use Model as BaseModel; | |
use Illuminate\Support\Facades\Validator; | |
// registrate own validator | |
Validator::resolver(function($translator, $data, $rules, $messages) { | |
return new ExtendedValidator($translator, $data, $rules, $messages); | |
}); | |
class Model extends BaseModel { | |
public $rules = [ | |
'name' => 'required|max:10', | |
'birth_number' => 'required|regex:/[0-9]{9,10}/|birthNumber' | |
]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment