Ubiquity 2.5.2
php rapid development framework
Loading...
Searching...
No Matches
LessThanValidator.php
Go to the documentation of this file.
1<?php
2
4
5use Ajax\semantic\components\validation\CustomRule;
6use Ajax\semantic\components\validation\Rule;
8
10 protected $ref;
11
12 public function __construct() {
13 $this->message = 'This value should be smaller than `{ref}`';
14 }
15
16 public function validate($value) {
17 parent::validate ( $value );
18 if ($this->notNull !== false) {
19 return $value < $this->ref;
20 }
21 return true;
22 }
23
29 public function getParameters(): array {
30 return [ 'ref','value' ];
31 }
32
38 public function asUI(): array {
39 $rule=new CustomRule('lessthan',"function(v,lessThan){ return v<lessThan;}",$this->_getMessage(),$this->ref);
40 return \array_merge_recursive(parent::asUI () , ['rules'=>[$rule]]);
41 }
42}
43
getParameters()
{{}\Ubiquity\contents\validation\validators\ValidatorInterfacegetParameters()}