1 | /**
|
2 | * @copyright Copyright (c) 2019 Maxim Khorin <maksimovichu@gmail.com>
|
3 | */
|
4 | ;
|
5 |
|
6 | const Base = require('./Validator');
|
7 |
|
8 | module.exports = class InlineValidator extends Base {
|
9 |
|
10 | constructor (config) {
|
11 | super({
|
12 | method: null,
|
13 | params: null,
|
14 | ...config
|
15 | });
|
16 | }
|
17 |
|
18 | validateAttr (attr, model) {
|
19 | const method = this.method;
|
20 | return typeof method === 'string'
|
21 | ? model[method](attr, this.params)
|
22 | : method.call(model, attr, model, this.params);
|
23 | }
|
24 | }; |
\ | No newline at end of file |