Giter VIP home page Giter VIP logo

Comments (5)

brzuchal avatar brzuchal commented on August 23, 2024 2

@alcohol sorry but I don't follow, what autocomplete? This is not a JS frontend library we would use for autocompletion, instead we use it in integration systems to lookup for appropriate country details based on user input. Therefore you can't just state that this is not a bug rather a feature, this is at least inappropriate!
IMO the return should be null in this case or at least throw an exception.

from iso3166.

alcohol avatar alcohol commented on August 23, 2024

Aside from name(), the other public methods implement guards. Perhaps the same could be done for name(). Although I am not sure if this is really an issue to begin with. There is no contract or definition for what should be returned if you search for an empty string. Since name() functions somewhat like an autocomplete, returning the first result from the set for an empty search string could be considered a graceful way to "fail".

from iso3166.

brzuchal avatar brzuchal commented on August 23, 2024

@alcohol so if I search for a string, should I also make sure that the country I end up with is actually the one I was looking for?
I'm afraid that approach seems like a recipe for messing things up without really trying.

from iso3166.

alcohol avatar alcohol commented on August 23, 2024

I do not follow. If you search for a string through the name() method, you can expect a result in an autocomplete like manner. If you want to be sure of the returned value, I suggest working with alpha 2 or 3 codes instead. They always map 1:1 to their designated value.

from iso3166.

amodliszewski avatar amodliszewski commented on August 23, 2024

@alcohol
Following description of method.

@throws \League\ISO3166\Exception\OutOfBoundsException if key does not exist in dataset

I believe empty string is non-existing key, also any one letter key should then end up on that exception, as I'm quite sure it does not exist same as empty string. It should be strict behaviour.

from iso3166.

Related Issues (20)

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.