@@ -60,7 +60,7 @@ |
||
60 | 60 | // search $needle in process status |
61 | 61 | $result = array_filter( |
62 | 62 | $process_status, |
63 | - function ($var) use ($needle) { |
|
63 | + function ($var) use ($needle){ |
|
64 | 64 | return strpos($var, $needle); |
65 | 65 | } |
66 | 66 | ); |
@@ -31,7 +31,7 @@ |
||
31 | 31 | */ |
32 | 32 | public function passes($attribute, $value) |
33 | 33 | { |
34 | - return $value->contains(function ($object) { |
|
34 | + return $value->contains(function ($object){ |
|
35 | 35 | $object->getRelationValue($this->relationName)->is($this->relationValue); |
36 | 36 | }); |
37 | 37 | } |
@@ -19,12 +19,14 @@ |
||
19 | 19 | * https://laraveldaily.com/how-to-create-custom-validation-rules-laravel/ |
20 | 20 | */ |
21 | 21 | |
22 | - public function passes($attribute, $value) { |
|
22 | + public function passes($attribute, $value) |
|
23 | + { |
|
23 | 24 | $passwordPattern = "~^.*(?=.{3,})(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[.!@#$%^&*]).*$~"; |
24 | 25 | return preg_match($passwordPattern, $value); |
25 | 26 | } |
26 | 27 | |
27 | - public function message() { |
|
28 | + public function message() |
|
29 | + { |
|
28 | 30 | return Lang::get('validation.custom.password'); |
29 | 31 | } |
30 | 32 |
@@ -46,7 +46,7 @@ |
||
46 | 46 | // debugbar()->debug($value); |
47 | 47 | // debugbar()->debug($this->attributeName); |
48 | 48 | // debugbar()->debug($this->attributeValue); |
49 | - return $this->array_any($value, function ($object) { |
|
49 | + return $this->array_any($value, function ($object){ |
|
50 | 50 | return $object[$this->attributeName] == $this->attributeValue; |
51 | 51 | }); |
52 | 52 | } |
@@ -7,7 +7,7 @@ |
||
7 | 7 | use App\Models\Applicant; |
8 | 8 | use App\Services\Validation\Rules\UniqueApplicantSkillRule; |
9 | 9 | class CourseValidator |
10 | -{ |
|
10 | +{ |
|
11 | 11 | |
12 | 12 | protected $applicant; |
13 | 13 | protected $course_status_id; |
@@ -7,17 +7,20 @@ discard block |
||
7 | 7 | use Illuminate\Support\Facades\Validator; |
8 | 8 | use Illuminate\Validation\Rule; |
9 | 9 | |
10 | -class JobApplicationAnswerValidator { |
|
10 | +class JobApplicationAnswerValidator |
|
11 | +{ |
|
11 | 12 | |
12 | 13 | protected $application; |
13 | 14 | protected $questionIds; |
14 | 15 | |
15 | - public function __construct(JobApplication $application) { |
|
16 | + public function __construct(JobApplication $application) |
|
17 | + { |
|
16 | 18 | $this->application = $application; |
17 | 19 | $this->questionIds = $application->job_poster->job_poster_questions->pluck('id')->toArray(); |
18 | 20 | } |
19 | 21 | |
20 | - public function rules() { |
|
22 | + public function rules() |
|
23 | + { |
|
21 | 24 | $rules = [ |
22 | 25 | 'answer' => 'required|string', |
23 | 26 | 'job_poster_question_id' => [ |
@@ -32,17 +35,20 @@ discard block |
||
32 | 35 | return $rules; |
33 | 36 | } |
34 | 37 | |
35 | - public function validator(JobApplicationAnswer $answer) { |
|
38 | + public function validator(JobApplicationAnswer $answer) |
|
39 | + { |
|
36 | 40 | |
37 | 41 | |
38 | 42 | return Validator::make($answer->toArray(), $this->rules()); |
39 | 43 | } |
40 | 44 | |
41 | - public function validate(JobApplicationAnswer $answer) { |
|
45 | + public function validate(JobApplicationAnswer $answer) |
|
46 | + { |
|
42 | 47 | return $this->validator($answer)->validate(); |
43 | 48 | } |
44 | 49 | |
45 | - public function isComplete(JobApplicationAnswer $answer) { |
|
50 | + public function isComplete(JobApplicationAnswer $answer) |
|
51 | + { |
|
46 | 52 | return $this->validator($answer)->passes(); |
47 | 53 | } |
48 | 54 | } |
@@ -21,7 +21,8 @@ |
||
21 | 21 | ]; |
22 | 22 | } |
23 | 23 | |
24 | - public function messages() { |
|
24 | + public function messages() |
|
25 | + { |
|
25 | 26 | return Lang::get('validation.custom.password'); |
26 | 27 | } |
27 | 28 | } |
@@ -29,7 +29,8 @@ |
||
29 | 29 | |
30 | 30 | } |
31 | 31 | |
32 | - public function validator(SkillDeclaration $skillDeclaration) { |
|
32 | + public function validator(SkillDeclaration $skillDeclaration) |
|
33 | + { |
|
33 | 34 | $uniqueSkillRule = new UniqueApplicantSkillRule($this->applicant, $skillDeclaration->id); |
34 | 35 | |
35 | 36 | //Validate basic data is filled in |
@@ -13,19 +13,22 @@ discard block |
||
13 | 13 | use App\Services\Validation\Rules\ContainsObjectWithAttributeRule; |
14 | 14 | use App\Services\Validation\JobApplicationAnswerValidator; |
15 | 15 | |
16 | -class ApplicationValidator { |
|
16 | +class ApplicationValidator |
|
17 | +{ |
|
17 | 18 | |
18 | 19 | protected $citizenship_ids; |
19 | 20 | protected $veteran_status_ids; |
20 | 21 | protected $preferred_language_ids; |
21 | 22 | |
22 | - public function __construct() { |
|
23 | + public function __construct() |
|
24 | + { |
|
23 | 25 | $this->citizenship_ids = CitizenshipDeclaration::all()->pluck('id')->toArray(); |
24 | 26 | $this->veteran_status_ids = VeteranStatus::all()->pluck('id')->toArray(); |
25 | 27 | $this->preferred_language_ids = PreferredLanguage::all()->pluck('id')->toArray(); |
26 | 28 | } |
27 | 29 | |
28 | - public function validate(JobApplication $application) { |
|
30 | + public function validate(JobApplication $application) |
|
31 | + { |
|
29 | 32 | |
30 | 33 | $backendRules = [ |
31 | 34 | 'job_poster_id' => 'required', |
@@ -75,9 +78,10 @@ discard block |
||
75 | 78 | return $newArray; |
76 | 79 | } |
77 | 80 | |
78 | - protected function addNestedValidatorRules($nestedAttribute, $validatorRules, $rules = []) { |
|
81 | + protected function addNestedValidatorRules($nestedAttribute, $validatorRules, $rules = []) |
|
82 | + { |
|
79 | 83 | // prepend the attribute name of each validator rule with the nested attribute name |
80 | - $newRules = $this->arrayMapKeys(function($key) use ($nestedAttribute) { |
|
84 | + $newRules = $this->arrayMapKeys(function($key) use ($nestedAttribute){ |
|
81 | 85 | return implode('.', [$nestedAttribute, $key]); |
82 | 86 | }, |
83 | 87 | $validatorRules); |
@@ -86,7 +90,8 @@ discard block |
||
86 | 90 | return $rules; |
87 | 91 | } |
88 | 92 | |
89 | - public function basicsValidator(JobApplication $application) { |
|
93 | + public function basicsValidator(JobApplication $application) |
|
94 | + { |
|
90 | 95 | // Validate the fields common to every application |
91 | 96 | $rules = [ |
92 | 97 | 'language_requirement_confirmed' => ['required', 'boolean'], |
@@ -116,21 +121,25 @@ discard block |
||
116 | 121 | return $validator; |
117 | 122 | } |
118 | 123 | |
119 | - public function basicsComplete(JobApplication $application) { |
|
124 | + public function basicsComplete(JobApplication $application) |
|
125 | + { |
|
120 | 126 | $validator = $this->basicsValidator($application); |
121 | 127 | return $validator->passes(); |
122 | 128 | } |
123 | 129 | |
124 | - public function experienceValidator(JobApplication $application) { |
|
130 | + public function experienceValidator(JobApplication $application) |
|
131 | + { |
|
125 | 132 | $rules = ['experience_saved' => 'required|boolean|accepted']; |
126 | 133 | return Validator::make($application->toArray(), $rules); |
127 | 134 | } |
128 | 135 | |
129 | - public function experienceComplete(JobApplication $application) { |
|
136 | + public function experienceComplete(JobApplication $application) |
|
137 | + { |
|
130 | 138 | return $this->experienceValidator($application)->passes(); |
131 | 139 | } |
132 | 140 | |
133 | - protected function skillsValidator(JobApplication $application, $criteria_type) { |
|
141 | + protected function skillsValidator(JobApplication $application, $criteria_type) |
|
142 | + { |
|
134 | 143 | $rules = []; |
135 | 144 | |
136 | 145 | $skillDeclarationRules = []; |
@@ -157,23 +166,28 @@ discard block |
||
157 | 166 | return $validator; |
158 | 167 | } |
159 | 168 | |
160 | - public function essentialSkillsValidator(JobApplication $application) { |
|
169 | + public function essentialSkillsValidator(JobApplication $application) |
|
170 | + { |
|
161 | 171 | return $this->skillsValidator($application, 'essential'); |
162 | 172 | } |
163 | 173 | |
164 | - public function essentialSkillsComplete(JobApplication $application) { |
|
174 | + public function essentialSkillsComplete(JobApplication $application) |
|
175 | + { |
|
165 | 176 | return $this->essentialSkillsValidator($application)->passes(); |
166 | 177 | } |
167 | 178 | |
168 | - public function assetSkillsValidator(JobApplication $application) { |
|
179 | + public function assetSkillsValidator(JobApplication $application) |
|
180 | + { |
|
169 | 181 | return $this->skillsValidator($application, 'asset'); |
170 | 182 | } |
171 | 183 | |
172 | - public function assetSkillsComplete(JobApplication $application) { |
|
184 | + public function assetSkillsComplete(JobApplication $application) |
|
185 | + { |
|
173 | 186 | return $this->assetSkillsValidator($application)->passes(); |
174 | 187 | } |
175 | 188 | |
176 | - public function affirmationValidator(JobApplication $application) { |
|
189 | + public function affirmationValidator(JobApplication $application) |
|
190 | + { |
|
177 | 191 | $rules = [ |
178 | 192 | 'submission_signature' => [ |
179 | 193 | 'required', |
@@ -189,7 +203,8 @@ discard block |
||
189 | 203 | return Validator::make($application->toArray(), $rules); |
190 | 204 | } |
191 | 205 | |
192 | - public function affirmationComplete(JobApplication $application) { |
|
206 | + public function affirmationComplete(JobApplication $application) |
|
207 | + { |
|
193 | 208 | return $this->affirmationValidator($application)->passes(); |
194 | 209 | } |
195 | 210 | } |