Hi,
The change I propose is the following:
When tipo is a NIE the rule for validate digitocontrols needs to replece the LetraInicial for the position of this array ["X", "Y, "Z"]. This means X replace with 0, Y replace with 1 and Z replace with 2.