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

Add character Ñ in validate #313

Closed chunchillo closed 4 years ago

chunchillo commented 4 years ago

Hi. Best regards.

could will consider on future versions add a "Ñ" in validators "alphas"? eg in "validate_alpha" change /^([a-zÀÁÂÃÄÅÇÈÉÊËÌÍÎÏÒÓÔÕÖßÙÚÛÜÝàáâãäåçèéêëìíîïðòóôõöùúûüýÿ])+$/i to /^([a-zñÑÀÁÂÃÄÅÇÈÉÊËÌÍÎÏÒÓÔÕÖßÙÚÛÜÝàáâãäåçèéêëìíîïðòóôõöùúûüýÿ])+$/i only add string ñÑ ... its help is for languaje spanish.

So, i have mi own class gump with this code for now =)

protected function validate_alpha($field, array $input, array $params = [], $value = null)
    {
        return preg_match('/^([a-zñÑÀÁÂÃÄÅÇÈÉÊËÌÍÎÏÒÓÔÕÖßÙÚÛÜÝàáâãäåçèéêëìíîïðòóôõöùúûüýÿ])+$/i', $value) > 0;
    }

protected function validate_alpha_numeric($field, array $input, array $params = [], $value)
    {
        return preg_match('/^([a-z0-9ñÑÀÁÂÃÄÅÇÈÉÊËÌÍÎÏÒÓÔÕÖßÙÚÛÜÝàáâãäåçèéêëìíîïðòóôõöùúûüýÿ])+$/i', $value) > 0;
    }

protected function validate_alpha_dash($field, array $input, array $params = [], $value)
    {
        return preg_match('/^([a-zñÑÀÁÂÃÄÅÇÈÉÊËÌÍÎÏÒÓÔÕÖßÙÚÛÜÝàáâãäåçèéêëìíîïðòóôõöùúûüýÿ_-])+$/i', $value) > 0;
    }

protected function validate_alpha_numeric_dash($field, array $input, array $params = [], $value)
    {
        return preg_match('/^([a-z0-9ñÑÀÁÂÃÄÅÇÈÉÊËÌÍÎÏÒÓÔÕÖßÙÚÛÜÝàáâãäåçèéêëìíîïðòóôõöùúûüýÿ_-])+$/i', $value) > 0;
    }

protected function validate_alpha_numeric_space($field, array $input, array $params = [], $value)
    {
        return preg_match("/^([a-z0-9ñÑÀÁÂÃÄÅÇÈÉÊËÌÍÎÏÒÓÔÕÖßÙÚÛÜÝàáâãäåçèéêëìíîïðòóôõöùúûüýÿ\s])+$/i", $value) > 0;
    }

protected function validate_alpha_space($field, array $input, array $params = [], $value)
    {
        return preg_match("/^([a-zñÑÀÁÂÃÄÅÇÈÉÊËÌÍÎÏÒÓÔÕÖßÙÚÛÜÝàáâãäåçèéêëìíîïðòóôõöùúûüýÿ\s])+$/i", $value) > 0;
    }

Thanks so much for your work!

filisko commented 4 years ago

can you create a Pull request?