Completed
Push — master ( db029f...19202d )
by Restu
16:00
created

RequiredRule   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 19
rs 10
wmc 3
lcom 1
cbo 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A isValid() 0 12 3
1
<?php
2
namespace JayaCode\Framework\Core\Validator\Rule;
3
4
use JayaCode\Framework\Core\Lang\Lang;
5
6
/**
7
 * Class RequiredRule
8
 * @package JayaCode\Framework\Core\Validator\Rule
9
 */
10
class RequiredRule extends Rule
11
{
12
13
    /**
14
     * @return bool
15
     */
16
    public function isValid()
17
    {
18
        if ($this->data === null || empty($this->data)) {
19
            $this->setErrorMessage($this->attributes["validatorName"], Lang::get("validator.required", [
20
                'name' => $this->attributes["name"]
21
            ], "The {name} field is required."));
22
23
            return false;
24
        }
25
26
        return true;
27
    }
28
}
29