File tree Expand file tree Collapse file tree 3 files changed +53
-2
lines changed Expand file tree Collapse file tree 3 files changed +53
-2
lines changed Original file line number Diff line number Diff line change @@ -6,6 +6,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
66
77## [ Unreleased]
88
9+ ## [ 0.3.1] - 2020-12-17
10+ ### Fixed
11+ - Validation checking mechanism adapted to handle the vat checking flow correctly
912## [ 0.3.0] - 2020-12-16
1013### Added
1114- Support for vat_eu_if: field ,compare_value
Original file line number Diff line number Diff line change @@ -85,7 +85,11 @@ public function boot()
8585 try {
8686 $ data = $ validator ->getData ();
8787
88- if (isset ($ data [$ parameters [0 ]]) === false || $ data [$ parameters [0 ]] != $ parameters [1 ]) {
88+ if ($ parameters [1 ] === 'true ' || $ parameters [1 ] === 'false ' ) {
89+ $ parameters [1 ] = $ parameters [1 ] === 'true ' ;
90+ }
91+
92+ if (isset ($ data [$ parameters [0 ]]) === false || $ data [$ parameters [0 ]] !== $ parameters [1 ]) {
8993 return true ;
9094 }
9195
@@ -102,6 +106,10 @@ public function boot()
102106 try {
103107 $ data = $ validator ->getData ();
104108
109+ if ($ parameters [2 ] === 'true ' || $ parameters [2 ] === 'false ' ) {
110+ $ parameters [2 ] = $ parameters [2 ] === 'true ' ;
111+ }
112+
105113 if (isset ($ data [$ parameters [0 ]]) === false || isset ($ data [$ parameters [1 ]]) === false ) {
106114 // Required fields does not exists in the provided input
107115 return false ;
@@ -113,7 +121,7 @@ public function boot()
113121 return true ;
114122 }
115123
116- if ($ data [$ parameters [1 ]] != $ parameters [2 ]) {
124+ if ($ data [$ parameters [1 ]] !== $ parameters [2 ]) {
117125 return true ;
118126 }
119127
Original file line number Diff line number Diff line change @@ -209,4 +209,44 @@ public function testIfValidationExtentionsVatEuAddressAndIfFailsIfCountryIsNotFr
209209 // Test
210210 $ this ->assertFalse ($ validator ->fails ());
211211 }
212+
213+ public function testIfValidationExtentinsVatEuIfThrowsExeception ():void
214+ {
215+
216+ // Prepare
217+ $ data = [
218+ 'vatid ' => 'XXX ' ,
219+ 'company ' => true ,
220+ ];
221+
222+ $ rules = [
223+ 'vatid ' => 'vat_eu_if:company,true ' ,
224+ ];
225+
226+ // Execute
227+ $ validator = Validator::make ($ data , $ rules );
228+
229+ // Test
230+ $ this ->assertTrue ($ validator ->fails ());
231+ }
232+
233+ public function testIfValidationExtentinsVatEuIfWorksIfCompanyIsFalse ():void
234+ {
235+
236+ // Prepare
237+ $ data = [
238+ 'vatid ' => 'XXX ' ,
239+ 'company ' => false ,
240+ ];
241+
242+ $ rules = [
243+ 'vatid ' => 'vat_eu_if:company,true ' ,
244+ ];
245+
246+ // Execute
247+ $ validator = Validator::make ($ data , $ rules );
248+
249+ // Test
250+ $ this ->assertFalse ($ validator ->fails ());
251+ }
212252}
You can’t perform that action at this time.
0 commit comments