All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.apache.commons.validator.routines.LEIValidator Maven / Gradle / Ivy

/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.apache.commons.validator.routines;

import org.apache.commons.validator.routines.checkdigit.Modulus97CheckDigit;

/**
 * LEI (Legal Entity Identifier) Validator.
 * 

* The Legal Entity Identifier (LEI) is a unique global identifier for legal entities participating in financial transactions. * Also known as an LEI code or LEI number, see Wikipedia. * The schema can be found in the most recent version of the * ISO 6523 ICD list. * The prefix of this specfic ICD identifier is 0199. *

* There are two formats, the actual style and the old style. *

* Example:
* 54930084UKLVMY22DS16 for G.E. Financing GmbH *
* 213800WSGIIZCXF1P572 Jaguar Land Rover Ltd *
* M07J9MTYHFCSVRBV2631 RWE AG (old Style, before 2012.Nov.30) *

*/ public class LEIValidator { private static final String[] FORMAT = new String[] { "^(\\d{4})([A-Z0-9]{14})(\\d{2})$" // (LOU)(two reserved + LEI)(two mandatory check digits) , "^([A-Z0-9]{18})(\\d{2})$" // old Style }; private static final int CODE_LEN = 20; private static final CodeValidator VALIDATOR = new CodeValidator(new RegexValidator(FORMAT), CODE_LEN, Modulus97CheckDigit.getInstance()); /** The singleton instance which uses the default formats */ private static final LEIValidator DEFAULT_LEI_VALIDATOR = new LEIValidator(); /** * Return a singleton instance of the validator using the default formats * * @return A singleton instance of the validator */ public static LEIValidator getInstance() { return DEFAULT_LEI_VALIDATOR; } /** * Validate a LEI * * @param id The value validation is being performed on * @return true if the value is valid */ public boolean isValid(String id) { return VALIDATOR.isValid(id); } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy