Wixel / GUMP

A fast, extensible & stand-alone PHP input validation class that allows you to validate any data
https://wixelhq.com
MIT License
1.17k stars 341 forks source link

Filter Rules are not working for Form array inputs #331

Closed damithdex closed 2 years ago

damithdex commented 2 years ago

This is the post array after applying filter rules. I just tired the upper_case and trim filters but those are only applying to primary array elements such as company name, short code. Filters do not apply to sub array elements such as first name, last name etc.. Please note that validation rules are working properly.

Array
(
    [company_name] => ABC COMPANY PLTD
    [short_code] => ABCCOM
    [company_address] => 
    [city] => 
    [lst_country] => 189
    [cn] => Array
        (
            [0] => Array
                (
                    [lst_title] => Mr 
                    [first_name] => johne
                    [last_name] =>      matin
                    [mobile] => 
                    [email] => 
                )

        )

    [frmSave] => 1
)
machernator commented 2 years ago

GUMP works on a one level array of values. One simple solution would be to take array values out of the configuration and create a separate Validator for these array values.

Another solution would be to create an array Validator that does that for you. But where to stop? I had forms with three array levels. You could do some form of recursive validation, but how do you manage the error messages? So I think it is easier to let GuMP do what it can do well and manually program the array validations.