Added isFreightContainerID validator by songyuew · Pull Request #2144 · validatorjs/validator.js

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)