Jump to content

Address: DNI is incorrect


z72diego

Recommended Posts

Hello everyone, I have a problem with version 1.6.0.11 of PrestaShop.

Some DNI that the clients enter when registering an address in the site gives them error:

1. dni is incorrect
2. The identification number is incorrect or has already been used

But, the strange thing about all this is that it happens only with some numbers, for example: this DNI gives error: ⁠⁠⁠29911444, but this other one does not: 19911444 .. this ID also does not give error: 11111111, but this one does: ⁠28911444 and also this: ⁠2891144

In the file validate.php i verified the field dni and I changed it by the following:

    {
        return empty($dni) || (bool)preg_match('/^[+0-9. ()-]*$/', $dni);
        /* return preg_match('/^[^<>;={}]*$/u', $dni); */
    }
I clarify that none of the numbers entered are DNI addresses registered in the store.
 
In AdminAddressesController.php i have the following:

if (Country::isNeedDniByCountryId(Tools::getValue('id_country')) && !Tools::getValue('dni'))
            $this->errors[] = Tools::displayError('The identification number is incorrect or has already been used.');

Any help? Thanks.

Edited by z72diego (see edit history)
Link to comment
Share on other sites

Below is the latest version of the isDniLite validate function (taken from PS v1.6.1.13).  Note: That is identical to the PS v1.6.0.11 version, however you appear to have something else commented in your function

/* return preg_match('/^[^<>;={}]*$/u', $dni); */

Was that from your original file?

 

 

This is from PS v1.6.1.13

    /**
     * @param string $dni to validate
     * @return bool
     */
    public static function isDniLite($dni)
    {
        return empty($dni) || (bool)preg_match('/^[0-9A-Za-z-.]{1,16}$/U', $dni);
    }
Edited by bellini13 (see edit history)
Link to comment
Share on other sites

 

Below is the latest version of the isDniLite validate function (taken from PS v1.6.1.13).  Note: That is identical to the PS v1.6.0.11 version, however you appear to have something else commented in your function

/* return preg_match('/^[^<>;={}]*$/u', $dni); */

Was that from your original file?

 

 

This is from PS v1.6.1.13

    /**
     * @param string $dni to validate
     * @return bool
     */
    public static function isDniLite($dni)
    {
        return empty($dni) || (bool)preg_match('/^[0-9A-Za-z-.]{1,16}$/U', $dni);
    }

 

Hello Michael,

 

Yes, I tried to modify that line of code to see what happened. The comment is one of the tests I did (Also did not work).

My original Validate.php was identical to the one you mentioned:

    /**
     * @param string $dni to validate
     * @return bool
     */
    public static function isDniLite($dni)
    {
        return empty($dni) || (bool)preg_match('/^[0-9A-Za-z-.]{1,16}$/U', $dni);
    }
But with that same format of validation I found the error for the first time.

 

It's weird, I do not understand why it accepts 11111111 but not ⁠⁠⁠29911444.

 

A customer placed an order yesterday and indicated this number and apparently had no problems: 38358088

 

Thanks!!

Edited by z72diego (see edit history)
Link to comment
Share on other sites

⁠⁠⁠29911444 has some invalid character embedded in it.  It's not visible unless you try to copy/paste it into a text editor and save it using ANSI encoding. 

 

Instead of doing a copy/paste of what the user provided, do a test where you just type in the value 29911444 and you will see it works fine.

 

You may need to add some other type of validation to capture this encoding issue

Link to comment
Share on other sites

⁠⁠⁠29911444 has some invalid character embedded in it.  It's not visible unless you try to copy/paste it into a text editor and save it using ANSI encoding. 

 

Instead of doing a copy/paste of what the user provided, do a test where you just type in the value 29911444 and you will see it works fine.

 

You may need to add some other type of validation to capture this encoding issue

 

You are the best Michael!! Problem solved :)

 

I await your e-mail answer, thanks again!!!
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...