A robust JavaScript library for validating Legal Entity Identifiers (LEIs) according to the ISO 17442 standard.
- ✅ Complete LEI validation according to ISO 17442
- 🔍 Detailed error reporting
- 🧩 LEI component breakdown
- 🔢 Check digit generation
- 💪 TypeScript-friendly with JSDoc annotations
<script src="//cdn.jsdelivr.net/gh/mczen-technologies/lei-validator@latest/index.js"></script>
const validator = new LEIValidator("213800D1L3R2MWV39G88");
const isValid = validator.isValid();
console.log(isValid ? "Valid LEI" : "Invalid LEI");
const validator = new LEIValidator("213800D1L3R2MWV39G88");
const result = validator.validate();
if (result.isValid) {
console.log("Valid LEI");
} else {
console.log("Invalid LEI:", result.errors);
}
const validator = new LEIValidator("213800D1L3R2MWV39G88");
const parts = validator.getParts();
console.log(parts);
// Output:
// {
// louPrefix: "2138",
// entityPart: "00D1L3R2MWV39G",
// checkDigits: "88"
// }
const checkDigits = LEIValidator.generateCheckDigits("213800D1L3R2MWV39G");
console.log("Check digits:", checkDigits);
An LEI is a 20-character identifier that consists of:
-
LOU Prefix (Characters 1-4):
- Identifies the Local Operating Unit that issued the LEI
- Alphanumeric characters only
-
Entity-Specific Part (Characters 5-18):
- Unique to the entity
- Alphanumeric characters only
-
Check Digits (Characters 19-20):
- Two numeric characters
- Calculated using ISO 17442 algorithm
The validator checks:
- Length (must be exactly 20 characters)
- Character set (uppercase alphanumeric only)
- LOU prefix format
- Entity-specific part format
- Check digits using MOD 97-10 algorithm
const validator = new LEIValidator(lei: string)
Throws TypeError
if the input is not a string.
Returns whether the LEI is valid.
Returns detailed validation results.
interface ValidationResult {
isValid: boolean;
errors: string[];
}
Returns the components of the LEI.
{
louPrefix: string;
entityPart: string;
checkDigits: string;
}
Generates valid check digits for a partial LEI (first 18 characters).
The validator provides detailed error messages for:
- Invalid input types
- Incorrect length
- Invalid characters
- Invalid LOU prefix
- Invalid entity-specific part
- Invalid check digits
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature
) - Commit your changes (
git commit -m 'Add some AmazingFeature'
) - Push to the branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- ISO 17442 standard for LEI structure
- GLEIF (Global Legal Entity Identifier Foundation) for LEI specifications
- Initial release
- Basic LEI validation
- Component breakdown
- Check digit generation
- Detailed error reporting