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

ContactFormOwner::validationDefault()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 7
c 0
b 0
f 0
nc 1
nop 1
dl 0
loc 12
rs 10
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\Schema;
16
use Cake\Validation\Validator;
17
18
class ContactFormOwner extends ContactForm
19
{
20
21
    /**
22
     * {@inheritdoc}
23
     *
24
     * @param \Cake\Form\Schema $schema The schema to customize.
25
     * @return \Cake\Form\Schema The schema to use.
26
     */
27
    protected function _buildSchema(Schema $schema): Schema
28
    {
29
        $schema = parent::_buildSchema($schema);
30
        $schema->addField('sender_contact', 'string');
31
32
        return $schema;
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('sender_contact')
45
            ->add('sender_contact', [
46
                'isEmail' => [
47
                    'rule' => ['email', true],
48
                    'message' => __('error_email_not-valid'),
49
                ],
50
            ]);
51
52
        return $validator;
53
    }
54
}
55