@@ -4,6 +4,100 @@ Container-validator-JS
44Cargo container validator ISO 6346 implemented in Javascript
55
66
7+ Install
8+ =======
9+
10+ ``` html
11+ <script type =" text/javascript" src =" ContainerValidator.js" ></script >
12+ ```
13+
14+
15+
16+ Documentation
17+ =============
18+
19+ Validate container ISO codes (TEXU3070079 = valid, TEXU3070070 != valid)
20+
21+ ``` javascript
22+ validator = new ContainerValidator ();
23+ validator .isValid (' TEXU3070079' ); // boolean true
24+ validator .isValid (' TEXU3070070' ); // boolean false
25+ ```
26+
27+ To get the diffrent segments from the code you can do,
28+
29+ ``` javascript
30+ container = validator .validate (' TEXU3070079' );
31+ console .log (container); // Array ( [0] => TEXU3070079 [1] => TEX [2] => U [3] => 307007 [4] => 9 )
32+ ```
33+ where:
34+
35+ ``` javascript
36+ array
37+ 0 => string ' TEXU3070079' // The code being validated
38+ 1 => string ' TEX' // The containers ownercode
39+ 2 => string ' U' // The containers group code
40+ 3 => string ' 307007' // The containers registration digit
41+ 4 => string ' 9' // The containers check digit
42+ ```
43+
44+ How to get error messages when the container code is invalid
45+
46+ ``` javascript
47+ validator .validate (' TEXU3070070' );
48+ validator .getErrorMessages (); // The check digit does not match
49+
50+ validator .validate (12345678910 );
51+ validator .getErrorMessages (); // The container number must be a string
52+
53+ validator .validate (' C3P0' );
54+ validator .getErrorMessages (); // The container number is invalid
55+ ```
56+
57+ Access information about the container:
58+ ``` javascript
59+ validator .validate (' TEXU3070070' );
60+ console .log (validator .getOwnerCode ()); // TEX
61+ console .log (validator .getProductGroupCode ()); // U
62+ console .log (validator .getRegistrationDigit ()); // 307007
63+ console .log (validator .getCheckDigit ()); // 9
64+ ```
65+
66+ Create a check digit to a container that does not have one
67+ ``` javascript
68+ validator = new ContainerValidator ();
69+ validator .createCheckDigit (' TEXU307007' ); // 9
70+ ```
71+
72+ Generate container numbers:
73+ ``` javascript
74+ // validator.generate( owner-code, product-group-code, number-start, number-end );
75+ validator = new ContainerValidator ();
76+ validator .generate (' TEX' ,' U' ,1 , 100 ));
77+ ```
78+
79+
80+
81+
82+
83+
84+ Credits
85+ =======
86+
87+
88+ Wonderpoint Software Pvt Ltd [ wonderpoint.com] ( http://www.wonderpoint.com )
89+
90+ Wikipedia : ISO 6346 [ wikipedia.org] ( http://en.wikipedia.org/wiki/ISO_6346 )
91+
92+ PHP Script : Patrik Stormpat [ github.com] ( https://github.com/stormpat/Container-validator )
93+
94+ PHP JS [ phpjs.org] ( http://phpjs.org )
95+
96+ Icons [ fancyicons.com] ( http://www.fancyicons.com/free-icon/108/gis-gps-icon-set/free-container-red-icon-png/ )
97+
98+ Salute to the original author,
99+ [ gedex.adc] ( http://www.google.com/gedex.web.id )
100+
7101
8102
9103License
0 commit comments