Passed
Branch feature/6.x (3df42d)
by Schlaefer
08:49
created

BlockForm::_buildValidator()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 6
nc 1
nop 1
dl 0
loc 9
rs 10
c 1
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
/**
6
 * Saito - The Threaded Web Forum
7
 *
8
 * @copyright Copyright (c) the Saito Project Developers
9
 * @link https://github.com/Schlaefer/Saito
10
 * @license http://opensource.org/licenses/MIT
11
 */
12
13
namespace App\Form;
14
15
use Cake\Form\Form;
16
use Cake\Form\Schema;
17
use Cake\Validation\Validator;
18
19
class BlockForm extends Form
20
{
21
22
    /**
23
     * {@inheritdoc}
24
     *
25
     * @param \Cake\Form\Schema $schema The schema to customize.
26
     * @return \Cake\Form\Schema The schema to use.
27
     */
28
    protected function _buildSchema(Schema $schema): Schema
29
    {
30
        return $schema
31
            ->addField('lockPeriod', ['type' => 'string'])
32
            ->addField('lockUserId', ['type' => 'string']);
33
    }
34
35
    /**
36
     * {@inheritdoc}
37
     *
38
     * @param \Cake\Validation\Validator $validator The validator to customize.
39
     * @return \Cake\Validation\Validator The validator to use.
40
     */
41
    public function validationDefault(Validator $validator): Validator
42
    {
43
        $validator
44
            ->notEmptyString('lockPeriod')
45
            ->add('lockPeriod', ['isNumeric' => ['rule' => ['numeric']]])
46
            ->notEmptyString('lockUserId')
47
            ->add('lockUserId', ['isNumeric' => ['rule' => ['numeric']]]);
48
49
        return $validator;
50
    }
51
}
52