Added isFreightContainerID validator#2144
Conversation
Codecov ReportBase: 100.00% // Head: 100.00% // No change to project coverage 👍
Additional details and impacted files@@ Coverage Diff @@
## master #2144 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 105 106 +1
Lines 2324 2348 +24
Branches 586 593 +7
=========================================
+ Hits 2324 2348 +24
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
src/lib/isContainerID.js
Outdated
There was a problem hiding this comment.
I feel like this could be rewritten to ^[0-9]$, since you are checking against each string character using its index, and that will always be just one character
Also maybe just a matter of taste in general, but this project seems to be generally prefering the use of regular expression literals. as opposed to a constructor function, like you used here.
So for the sake of style consistency, I would probably also suggest the following change:
new RegExp('^[0-9]{1}')-> const isDigit = /^[0-9]$/
(same applies to the isContainerIdReg regexp in line 4)
There was a problem hiding this comment.
Hi Panagiotis,
Thank you very much for pointing it out! I have updated the corresponding lines.
src/lib/isContainerID.js
Outdated
There was a problem hiding this comment.
I have the same concerns about this, as I have mentioned in your other PR:
#2143
what do you think?
README.md
Outdated
There was a problem hiding this comment.
I think the name might be a bit too unspecific, as "container ID" feels a bit too generic, e.g. just google it, brought up several hits, like e.g. "docker container ID", "Windows Drivers Container ID", etc.
So I would probably say it makes sense to rename this?
Options could be maybe:
- isShippingContainerID
- isISO6346ContainerID (that one does look ugly to be honest :-D)
- ?
What do you think?
There was a problem hiding this comment.
We already have some ISO standards so a simple isISO6346 could also suffice
There was a problem hiding this comment.
I have changed it to isISO6346, for consistency with other validators.
|
thank you for the PR :-) |
Haha thank you Panagiotis for reviewing my PR once again. |
|
This was also interesting to me, learned something new! Thanks for the PR! |
|
QQ, do you want to add |
|
Hi Nandaa, Do you mean adding a new file with the name of |
|
hi guys, one tiny thing I'd like to still see adressed is my comment above regarding the use of |
@songyuew -- not really a new file, just within the same file, exporting the |
@profnandaa @pano9000 Alias added and sanitization removed, plz kindly review, thanks! |
|
My bad, I don't know how we missed this one, should have gone into the previous release. I'll queue it up for the next one. |
profnandaa
left a comment
There was a problem hiding this comment.
LGTM. If you can fix the m/c, I'll merge it straight away.
Added isContainerID validator
Check whether a string is an ISO6346 shipping container identification.
https://en.wikipedia.org/wiki/ISO_6346
Please review my PR, thanks!
Checklist