Container-validator-JS
Cargo container validator ISO 6346 implemented in Javascript
Demo
container-validator.sameershemna.com
Install
<script type="text/javascript" src="index.js"></script>
Install using Yarn:
yarn add container-validator
Install using NPM:
npm install container-validator
Install using Bower:
bower install Container-validator-JS
Documentation
Validate container ISO codes (TEXU3070079 = valid, TEXU3070070 != valid)
validator = new ContainerValidator();
validator.isValid('TEXU3070079');
validator.isValid('TEXU3070070');
To get the diffrent segments from the code you can do,
container = validator.validate('TEXU3070079');
console.log(container);
where:
array
0 => string 'TEXU3070079'
1 => string 'TEX'
2 => string 'U'
3 => string '307007'
4 => string '9'
How to get error messages when the container code is invalid
validator.validate('TEXU3070070');
validator.getErrorMessages();
validator.validate(12345678910);
validator.getErrorMessages();
validator.validate('C3P0');
validator.getErrorMessages();
Access information about the container:
validator.validate('TEXU3070070');
console.log(validator.getOwnerCode());
console.log(validator.getProductGroupCode());
console.log(validator.getRegistrationDigit());
console.log(validator.getCheckDigit());
Create a check digit to a container that does not have one
validator = new ContainerValidator();
validator.createCheckDigit('TEXU307007');
Generate container numbers:
validator = new ContainerValidator();
validator.generate('TEX','U',1, 100 ));
Credits
Wonderpoint Software Pvt Ltd wonderpoint.com
Wikipedia : ISO 6346 wikipedia.org
PHP Script : Patrik Stormpat github.com
PHP JS phpjs.org
Icons fancyicons.com
Salute to the original author,
gedex.adc
License
The MIT License (MIT)
Copyright (c) 2014 sameersemna
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.