Ubiquity
2.5.2
php rapid development framework
Loading...
Searching...
No Matches
IdValidator.php
Go to the documentation of this file.
1
<?php
2
3
namespace
Ubiquity\contents\validation\validators\multiples
;
4
9
class
IdValidator
extends
ValidatorMultiple
{
10
protected
$autoinc
;
11
public
function
__construct
(){
12
parent::__construct();
13
$this->message=array_merge($this->message,[
14
'positive'
=>
'This value must be positive'
,
15
'type'
=>
'This value must be an integer'
16
]);
17
}
18
19
public
function
validate
(
$value
) {
20
if
(!parent::validate(
$value
)) {
21
return
false
;
22
}
23
if
(
$value
!=(
int
)
$value
){
24
$this->violation=
'type'
;
25
return
false
;
26
}
27
if
(
$value
<=0){
28
$this->violation=
'positive'
;
29
return
false
;
30
}
31
return
true
;
32
}
33
38
public
function
getParameters
(): array {
39
return [
'value'
];
40
}
45
protected
function
setParams
(array $params) {
46
parent::setParams($params);
47
if
($this->autoinc===
true
){
48
$this->notNull=
false
;
49
}
50
}
51
57
public
function
asUI
(): array {
58
$rules[] = [
'type'
=>
'regExp'
,
'prompt'
=> $this->_getMessage()[
'positive'
],
'value'
=>
'^[1-9]+$|^$'
];
59
return \array_merge_recursive(parent::asUI () , [
'inputType'
=>
'number'
,
'rules'
=> $rules]);
60
}
61
}
62
Ubiquity\contents\validation\validators\Validator\$value
$value
Definition
Validator.php:15
Ubiquity\contents\validation\validators\multiples\IdValidator
Validate int identifiers (notNull positive integer).
Definition
IdValidator.php:9
Ubiquity\contents\validation\validators\multiples\IdValidator\getParameters
getParameters()
{}\Ubiquity\contents\validation\validators\ValidatorInterfacegetParameters()
Definition
IdValidator.php:38
Ubiquity\contents\validation\validators\multiples\IdValidator\__construct
__construct()
Definition
IdValidator.php:11
Ubiquity\contents\validation\validators\multiples\IdValidator\setParams
setParams(array $params)
Definition
IdValidator.php:45
Ubiquity\contents\validation\validators\multiples\IdValidator\validate
validate($value)
Definition
IdValidator.php:19
Ubiquity\contents\validation\validators\multiples\IdValidator\$autoinc
$autoinc
Definition
IdValidator.php:10
Ubiquity\contents\validation\validators\multiples\IdValidator\asUI
asUI()
{}
Definition
IdValidator.php:57
Ubiquity\contents\validation\validators\multiples\ValidatorMultiple
Definition
ValidatorMultiple.php:10
Ubiquity\contents\validation\validators\multiples
Definition
IdValidator.php:3
C:
Users
myadd
Documents
GitHub
ubiquity-doc-api
vendor
phpmv
ubiquity
src
Ubiquity
contents
validation
validators
multiples
IdValidator.php
Generated on Sun Dec 10 2023 15:04:15 for
Ubiquity
by
doxygen
1.9.8