GithubHelp home page GithubHelp logo

panics if Rut starts with 00 about rut-lib HOT 6 OPEN

jfgodoy avatar jfgodoy commented on June 29, 2024
panics if Rut starts with 00

from rut-lib.

Comments (6)

erikjara avatar erikjara commented on June 29, 2024

Hola, @jfgodoy
Te agradezco muchísimo por levantar el issue, lamentablemente por el contexto que estamos teniendo no he revisado el proyecto y dudo tenerlo en el corto tiempo.

Entiendo que esto es solucionable con un Regex y/o String.replace de los primeros ceros que estén dentro de la entrada recibida, te agradecería a mil si pudieras enviar el PR, con gusto hago la revisión como merge de los cambios.

Muchos ánimos en estos tiempos complejos, y nuevamente gracias por esto.

from rut-lib.

EstebanBorai avatar EstebanBorai commented on June 29, 2024

Hi @erikjara and @jfgodoy! As #12 is already merged, I guess this should be closed, right?

from rut-lib.

jfgodoy avatar jfgodoy commented on June 29, 2024

yes, I'm agree 👍

from rut-lib.

erikjara avatar erikjara commented on June 29, 2024

@EstebanBorai @jfgodoy Thanks for the help in this issue! ❤

from rut-lib.

erikjara avatar erikjara commented on June 29, 2024
Original Text (Spanish)

@jfgodoy Disculpa las molestias, pero me estaba dando cuenta que admitir ceros en la entrada me parecía incorrecto, ya que la función de la librería es decirte si el RUT ingresado es uno de los formatos válidos, y si no, mostrar que es incorrecto.

Para este caso en particular, lo que voy a hacer es lo siguiente:
Primero, sí puedes mandar el PR nuevamente a la rama https://github.com/erikjara/rut-lib/tree/fix/parse-input-with-zeroes te lo agradecería muchísimo, te dejo el enlace aquí para que puedas crearlo rápidamente.

Después del merge (en modo rebase), haré un Negative Lookahead a la regla de cero que añadiste, y así realmente se arregla el problema que es evitar el panic de la librería con la entrada que señalaste en este problema.

@jfgodoy Sorry for the inconvenience, but I was realizing that admitting zeros in the input seemed wrong to me, since the function of the library is to tell you if the RUT input is one of the valid formats, and if not, show that it is wrong.

For this particular case, what I'm going to do is the following steps:
First, if you can send the PR again to the branch https://github.com/erikjara/rut-lib/tree/fix/parse-input-with-zeroes I would really appreciate it, I leave the link here, so you can create it quickly.

After the merge (rebase mode), I will do a Negative Lookahead to the zero rule that you added, and this really fixes the problem that is avoiding the panic with the input you pointed out in this problem.

from rut-lib.

EstebanBorai avatar EstebanBorai commented on June 29, 2024
Original Text (Spanish)

@jfgodoy Disculpa las molestias, pero me estaba dando cuenta que admitir ceros en la entrada me parecía incorrecto, ya que la función de la librería es decirte si el RUT ingresado es uno de los formatos válidos, y si no, mostrar que es incorrecto.

Para este caso en particular, lo que voy a hacer es lo siguiente:

Primero, sí puedes mandar el PR nuevamente a la rama https://github.com/erikjara/rut-lib/tree/fix/parse-input-with-zeroes te lo agradecería muchísimo, te dejo el enlace aquí para que puedas crearlo rápidamente.

Después del merge (en modo rebase), haré un Negative Lookahead a la regla de cero que añadiste, y así realmente se arregla el problema que es evitar el panic de la librería con la entrada que señalaste en este problema.

@jfgodoy Sorry for the inconvenience, but I was realizing that admitting zeros in the input seemed wrong to me, since the function of the library is to tell you if the RUT input is one of the valid formats, and if not, show that it is wrong.

For this particular case, what I'm going to do is the following steps:

First, if you can send the PR again to the branch https://github.com/erikjara/rut-lib/tree/fix/parse-input-with-zeroes I would really appreciate it, I leave the link here, so you can create it quickly.

After the merge (rebase mode), I will do a Negative Lookahead to the zero rule that you added, and this really fixes the problem that is avoiding the panic with the input you pointed out in this problem.

I'm agree with you, its kind of misleading to have a RUT being digested by the library and acting unsound if the RUT doesn't have the right format.

Thinking out loud...

I think the best approach is the one we have today, but we could also provide a "sanitize" function that attempts to fix the format and then digest it as we are doing now.

This way we don't break the current version by changing the internals of the API.

I would expect RUT numbers with preceding zeroes to return a Error::InvalidFormat error and have a Rut::sanitize that receives arbitrary RUT numbers, with preceding zeroes for instance, and retrieve them formatted.

This is always fine as long as you don't mess up with the RUT per se because we could mutate the real input by attempting to sanitize it.

Those are my 2¢ on this issue, but I think it would be great to have a description of what do you expect (speaking behavior) from this crate in such scenarios?

from rut-lib.

Related Issues (2)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.