Passed
Push — task/add-applicants-and-applic... ( 514472...36c932 )
by Yonathan
10:54 queued 12s
created

StrategicResponseApplicationValidator   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 19
c 1
b 0
f 0
dl 0
loc 47
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A basicInfoSimpleRules() 0 13 1
A detailedValidatorErrors() 0 7 1
A experienceValidator() 0 3 1
1
<?php
2
3
namespace App\Services\Validation;
4
5
use App\Models\JobApplication;
6
use Illuminate\Support\Facades\Validator;
7
use App\Services\Validation\Rules\GovernmentEmailRule;
8
9
class StrategicResponseApplicationValidator extends ApplicationValidator
10
{
11
    /**
12
     * OVERRIDE
13
     *
14
     * @return mixed[]
15
     */
16
    protected function basicInfoSimpleRules()
17
    {
18
        return [
19
            'preferred_language_id' => ['required', 'exists:preferred_languages,id'],
20
            'director_name' => ['required', 'string'],
21
            'director_title' => ['required', 'string'],
22
            'director_email' => ['required', 'email:rfc', 'max:191'],
23
            'reference_name' => ['required', 'string'],
24
            'reference_title' => ['required', 'string'],
25
            'reference_email' => ['required', 'email:rfc', 'max:191'],
26
            'gov_email' => ['required', new GovernmentEmailRule],
27
            'physical_office_willing' => 'required|boolean',
28
            'security_clearance_id' => ['required', 'exists:security_clearances,id'],
29
        ];
30
    }
31
32
    public $experienceRules = [];
33
34
    /**
35
     * OVERRIDE
36
     *
37
     * @return Validator
38
     */
39
    public function experienceValidator(JobApplication $application)
40
    {
41
        return Validator::make([], []);
42
    }
43
44
    /**
45
     * OVERRIDE
46
     *
47
     * @return mixed[]
48
     */
49
    public function detailedValidatorErrors(JobApplication $application)
50
    {
51
        return array_merge(
52
            Validator::make($application->toArray(), $this->backendRules)->errors()->all(),
53
            $this->basicsValidator($application)->errors()->all(),
54
            $this->essentialSkillsValidator($application)->errors()->all(),
55
            $this->affirmationValidator($application)->errors()->all()
56
        );
57
    }
58
}
59