Code Duplication    Length = 15-17 lines in 7 locations

plugins/Taxonomy/src/Model/Table/TermsTable.php 1 location

@@ 51-67 (lines=17) @@
48
     * @param \Cake\Validation\Validator $validator The validator object
49
     * @return \Cake\Validation\Validator
50
     */
51
    public function validationDefault(Validator $validator)
52
    {
53
        $validator
54
            ->requirePresence('name')
55
            ->add('name', [
56
                'notBlank' => [
57
                    'rule' => 'notBlank',
58
                    'message' => __d('taxonomy', 'You need to provide a name.'),
59
                ],
60
                'length' => [
61
                    'rule' => ['minLength', 3],
62
                    'message' => __d('taxonomy', 'Name need to be at least 3 characters long.'),
63
                ],
64
            ]);
65
66
        return $validator;
67
    }
68
}
69

plugins/Taxonomy/src/Model/Table/VocabulariesTable.php 1 location

@@ 46-62 (lines=17) @@
43
     * @param \Cake\Validation\Validator $validator The validator object
44
     * @return \Cake\Validation\Validator
45
     */
46
    public function validationDefault(Validator $validator)
47
    {
48
        $validator
49
            ->requirePresence('name')
50
            ->add('name', [
51
                'notBlank' => [
52
                    'rule' => 'notBlank',
53
                    'message' => __d('taxonomy', 'You need to provide a name.'),
54
                ],
55
                'length' => [
56
                    'rule' => ['minLength', 3],
57
                    'message' => __d('taxonomy', 'Name need to be at least 3 characters long.'),
58
                ],
59
            ]);
60
61
        return $validator;
62
    }
63
}
64

plugins/User/src/Model/Table/RolesTable.php 1 location

@@ 41-57 (lines=17) @@
38
     * @param \Cake\Validation\Validator $validator The validator object
39
     * @return \Cake\Validation\Validator
40
     */
41
    public function validationDefault(Validator $validator)
42
    {
43
        $validator
44
            ->requirePresence('name')
45
            ->add('name', [
46
                'notBlank' => [
47
                    'rule' => 'notBlank',
48
                    'message' => __d('user', 'You need to provide a role name.'),
49
                ],
50
                'length' => [
51
                    'rule' => ['minLength', 3],
52
                    'message' => __d('user', 'Role name need to be at least 3 characters long.'),
53
                ],
54
            ]);
55
56
        return $validator;
57
    }
58
}
59

plugins/Block/src/Model/Table/BlocksTable.php 1 location

@@ 237-251 (lines=15) @@
234
     * @param \Cake\Validation\Validator $validator The validator object
235
     * @return \Cake\Validation\Validator
236
     */
237
    public function validationCustom(Validator $validator)
238
    {
239
        return $this->validationWidget($validator)
240
            ->requirePresence('body')
241
            ->add('body', [
242
                'notBlank' => [
243
                    'rule' => 'notBlank',
244
                    'message' => __d('block', "You need to provide a content for block's body."),
245
                ],
246
                'length' => [
247
                    'rule' => ['minLength', 3],
248
                    'message' => __d('block', "Block's body need to be at least 3 characters long."),
249
                ],
250
            ]);
251
    }
252
253
    /**
254
     * Validates block settings before persisted in DB.

plugins/Field/src/Model/Table/FieldInstancesTable.php 1 location

@@ 104-120 (lines=17) @@
101
     * @param \Cake\Validation\Validator $validator The validator object
102
     * @return \Cake\Validation\Validator
103
     */
104
    public function validationDefault(Validator $validator)
105
    {
106
        $validator
107
            ->notEmpty('handler', __d('field', 'Invalid field type.'))
108
            ->add('label', [
109
                'notBlank' => [
110
                    'rule' => 'notBlank',
111
                    'message' => __d('field', 'You need to provide a label.'),
112
                ],
113
                'length' => [
114
                    'rule' => ['minLength', 3],
115
                    'message' => __d('field', 'Label need to be at least 3 characters long'),
116
                ],
117
            ]);
118
119
        return $validator;
120
    }
121
122
    /**
123
     * Instance's settings validator.

plugins/Locale/src/Model/Table/LanguagesTable.php 1 location

@@ 47-63 (lines=17) @@
44
     * @param \Cake\Validation\Validator $validator The validator object
45
     * @return \Cake\Validation\Validator
46
     */
47
    public function validationDefault(Validator $validator)
48
    {
49
        $validator
50
            ->add('name', [
51
                'notBlank' => [
52
                    'rule' => 'notBlank',
53
                    'message' => __d('locale', 'You need to provide a language name.'),
54
                ],
55
                'length' => [
56
                    'rule' => ['minLength', 3],
57
                    'message' => __d('locale', 'Language name need to be at least 3 characters long.'),
58
                ],
59
            ])
60
            ->requirePresence('code');
61
62
        return $validator;
63
    }
64
65
    /**
66
     * Regenerates system's snapshot.

plugins/Content/src/Model/Table/ContentsTable.php 1 location

@@ 171-186 (lines=16) @@
168
     * @param \Cake\Validation\Validator $validator The validator object
169
     * @return \Cake\Validation\Validator
170
     */
171
    public function validationDefault(Validator $validator)
172
    {
173
        $validator
174
            ->add('title', [
175
                'notBlank' => [
176
                    'rule' => 'notBlank',
177
                    'message' => __d('content', 'You need to provide a title.'),
178
                ],
179
                'length' => [
180
                    'rule' => ['minLength', 3],
181
                    'message' => __d('content', 'Title need to be at least 3 characters long.'),
182
                ],
183
            ]);
184
185
        return $validator;
186
    }
187
188
    /**
189
     * This callback performs two action, saving revisions and checking publishing