Form::createValidator()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 38
Code Lines 27

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 27
c 1
b 0
f 0
dl 0
loc 38
rs 9.488
cc 1
nc 1
nop 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace AbterPhp\Contact\Validation\Factory;
6
7
use Opulence\Validation\Factories\ValidatorFactory;
8
use Opulence\Validation\IValidator;
9
10
class Form extends ValidatorFactory
11
{
12
    /**
13
     * @return IValidator
14
     */
15
    public function createValidator(): IValidator
16
    {
17
        $validator = parent::createValidator();
18
19
        $validator
20
            ->field('id')
21
            ->forbidden();
22
23
        $validator
24
            ->field('identifier');
25
26
        $validator
27
            ->field('name')
28
            ->required();
29
30
        $validator
31
            ->field('to_name')
32
            ->required();
33
34
        $validator
35
            ->field('to_email')
36
            ->email()
37
            ->required();
38
39
        $validator
40
            ->field('success_url')
41
            ->required();
42
43
        $validator
44
            ->field('failure_url')
45
            ->required();
46
47
        $validator
48
            ->field('max_body_length')
49
            ->numeric()
50
            ->required();
51
52
        return $validator;
53
    }
54
}
55