validatorjs / validator.js

String validation
MIT License
23.1k stars 2.31k forks source link

Add alias GTIN for EAN #1353

Open karladler opened 4 years ago

karladler commented 4 years ago

As I see it the term EAN is gradually being deprecated in favour of GTIN, maybe we can add it as an alias for EAN?

profnandaa commented 4 years ago

PR welcome.

tux-tn commented 4 years ago

Isn't EAN a single type of GTIN more precisely GTIN-13 ?

rubiin commented 4 years ago

EAN is actually a type of gtin. Reference https://www.gtin.info/

vinod-designer1 commented 3 years ago

Hi, I want to work on this issue, right now only validation is available for 8,13, 14 digit code. We should add now for 12 digit code to satisfy all GTIN validations, and also where we validate the the given GTIN we need to use 3 for odd and 1 for even irrespective of length, but i saw in this function getPositionWeightThroughLengthAndIndex for 13 digit code it's reversed why?. Here is the reference to this https://en.wikipedia.org/wiki/International_Article_Number#:~:text=Numbering%20the%20positions%20from%20the%20right%20(code%20aligned%20to%20the%20right)%2C%20the%20odd%20data%20digits%20are%20always%20weight%20of%203%20and%20the%20even%20data%20digits%20are%20always%20weight%20of%201%2C%20regardless%20of%20the%20length%20of%20the%20code.

Let me know if i went wrong somewhere. Thanks