A lightweight TypeScript package to validate shipping container numbers according to the ISO 6346 standard.
- ✅ Validates container numbers using the ISO 6346 check digit algorithm
- 🪶 Lightweight with zero dependencies
- 📦 Supports both CommonJS and ES Modules
- 🔷 Full TypeScript support with type definitions
- ✨ Simple and intuitive API
npm install @mykelcodes/container-number-validation
# or
pnpm add @mykelcodes/container-number-validation
# or
yarn add @mykelcodes/container-number-validationimport { isValidContainer } from '@mykelcodes/container-number-validation';
console.log(isValidContainer('CCLU4843216')); // true
console.log(isValidContainer('CSQU3054390')); // falseconst { isValidContainer } = require('@mykelcodes/container-number-validation');
console.log(isValidContainer('CCLU4843216')); // true
console.log(isValidContainer('CSQU3054390')); // falseValidates a container number according to ISO 6346 standard.
Parameters:
containerNumber(string): The container number to validate (must be 11 characters)
Returns:
boolean:trueif the container number is valid,falseotherwise
Example:
isValidContainer('CCLU4843216'); // returns true
isValidContainer('INVALID1234'); // returns false
isValidContainer('SHORT'); // returns false (wrong length)A valid container number consists of:
- 4 letters: Owner code (3 letters) + Equipment category identifier (1 letter)
- 6 digits: Serial number
- 1 digit: Check digit (calculated using ISO 6346 algorithm)
Example: CCLU4843216
CCL: Owner codeU: Equipment category identifier484321: Serial number6: Check digit
# Install dependencies
pnpm install
# Run tests
pnpm test
# Build the package
pnpm build
# Format code
pnpm formatMIT © Michael Olawale
Contributions are welcome! Please feel free to submit a Pull Request.