File tree Expand file tree Collapse file tree 4 files changed +32
-6
lines changed Expand file tree Collapse file tree 4 files changed +32
-6
lines changed Original file line number Diff line number Diff line change @@ -11,7 +11,7 @@ public function getPillDataForFilter(): array
1111        $ filters
1212
1313        foreach  ($ this getAppliedFiltersWithValuesForPills () as  $ filterKey$ value
14-             if  (! is_null ($ filter$ this getFilterByKey ($ filterKey
14+             if  (! is_null ($ filter$ this getFilterByKey ($ filterKey && !  $ filter -> isEmpty ( $ filter -> validate ( $ value )) ) {
1515                $ filters$ filtergetKey ()] = FilterPillData::make (
1616                    filterKey: $ filtergetKey (),
1717                    customPillBlade: $ filtergetCustomPillBlade () ?? null ,
Original file line number Diff line number Diff line change @@ -49,11 +49,13 @@ public function getAppliedFiltersWithValuesForPills(): array
4949            }
5050
5151            $ validatedValue$ filtervalidate ($ item
52+ 
5253            if  ($ filterinstanceof  BooleanFilter) {
5354                return  ! ($ filterisEmpty ($ validatedValue
54-             } elseif  ($ validatedValuenull  || $ validatedValue'null ' ) {
55+             } elseif  ($ validatedValuenull  || $ validatedValue'null '  ||  $ filter -> isEmpty ( $ validatedValue ) ) {
5556                return  false ;
5657            } elseif  (is_array ($ validatedValue
58+                 $ filterisEmpty ($ validatedValue
5759                if  (array_key_exists (0 , $ validatedValueis_null ($ validatedValue0 ]) || $ validatedValue0 ] == 'null ' )) {
5860                    return  false ;
5961                }
Original file line number Diff line number Diff line change @@ -40,12 +40,10 @@ public function validate(array|string|null $values): array|bool
4040            return  false ;
4141        }
4242
43-         $ startDate$ this createCarbonDate ($ returnedValues'minDate ' ]);
44-         $ endDate$ this createCarbonDate ($ returnedValues'maxDate ' ]);
45- 
46-         if  (! ($ startDateinstanceof  Carbon) || ! ($ endDateinstanceof  Carbon)) {
43+         if  (! (($ startDate$ this createCarbonDate ($ returnedValues'minDate ' ])) instanceof  Carbon) || ! (($ endDate$ this createCarbonDate ($ returnedValues'maxDate ' ])) instanceof  Carbon)) {
4744            return  false ;
4845        }
46+ 
4947        if  ($ startDategt ($ endDate
5048            return  false ;
5149        }
@@ -198,6 +196,9 @@ public function getFilterPillValue($value): array|string|bool|null
198196
199197    public  function  isEmpty (array |string |null  $ valuebool 
200198    {
199+         if  (is_null ($ valueempty ($ value
200+             return  true ;
201+         }
201202        $ values
202203        if  (is_array ($ value
203204            if  (! isset ($ value'minDate ' ]) || ! isset ($ value'maxDate ' ])) {
Original file line number Diff line number Diff line change @@ -435,4 +435,27 @@ public function test_check_if_can_get_locale(): void
435435        $ this assertSame ('de ' , self ::$ filterInstancegetPillsLocale ());
436436        $ this assertTrue (self ::$ filterInstancehasPillsLocale ());
437437    }
438+ 
439+     public  function  test_can_check_validation_rejects_invalid_values_array (): void 
440+     {
441+         $ missingStartDateself ::$ filterInstancevalidate ([null , '2020-01-01 ' ]);
442+         $ missingEndDateself ::$ filterInstancevalidate (['2020-01-01 ' , null ]);
443+         $ missingBothself ::$ filterInstancevalidate ([null , null ]);
444+ 
445+         $ this assertFalse ($ missingStartDate
446+         $ this assertFalse ($ missingEndDate
447+         $ this assertFalse ($ missingBoth
448+         $ this assertTrue (self ::$ filterInstanceisEmpty ($ missingStartDate
449+         $ this assertTrue (self ::$ filterInstanceisEmpty ($ missingEndDate
450+         $ this assertTrue (self ::$ filterInstanceisEmpty ($ missingBoth
451+     }
452+ 
453+     public  function  test_can_check_validation_rejects_broken_values_array (): void 
454+     {
455+         $ this assertFalse (self ::$ filterInstancevalidate (['minDate '  => 'asdf ' , 'maxDate '  => '2020-02-02 ' ]));
456+         $ this assertFalse (self ::$ filterInstancevalidate (['minDate '  => '4121-31-31 ' , 'maxDate '  => '2020-02-02 ' ]));
457+         $ this assertFalse (self ::$ filterInstancevalidate (['minDate '  => '2020-02-02 ' , 'maxDate '  => 'asdf ' ]));
458+         $ this assertFalse (self ::$ filterInstancevalidate (['minDate '  => '2020-02-02 ' , 'maxDate '  => '4121-31-31 ' ]));
459+ 
460+     }
438461}
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments