Package com.irurueta.commons.validators
Class NIFValidator
- java.lang.Object
-
- com.irurueta.commons.validators.NIFValidator
-
public class NIFValidator extends java.lang.Object
Validates provided NIF (Número de Identificación Fiscal) values for Spain. This class is a wrapper for the library provided by Spain's Ministerio de Hacienda to validate DNI's, NIF's, NIE's, CIF's, etc.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
NIFValidator.Validador
Inner class to perform actual validation.
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.ref.SoftReference<NIFValidator.Validador>
mValRef
Reference to the internal validator provided by Ministerio de Hacienda.
-
Constructor Summary
Constructors Modifier Constructor Description protected
NIFValidator()
Constructor.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description private static NIFValidator.Validador
getOrCreateValidador()
Gets or creates singleton instance to validate DNI's, NIF's, CIF's, etc using the library provided by the Ministerio de Hacienda.static boolean
isValid(java.lang.String value)
Checks whether provided value is a valid DNI, NIF, NIE or CIF.static boolean
isValidCIF(java.lang.String value)
Checks whether provided value corresponds to a valid CIF (Código de Identificación Fiscal).static boolean
isValidCIFCode(int code)
Checks whether provided code corresponds to a valid CIF (Código de Identificación Fiscal).static boolean
isValidCIFNonResidents(java.lang.String value)
Checks whether provided value corresponds to a valid non-resident CIF.static boolean
isValidCIFNonResidentsCode(int code)
Checks whether provided code corresponds to a valid non-resident CIF.static boolean
isValidCIFOrganization(java.lang.String value)
Checks whether provided value corresponds to a valid Organization CIF.static boolean
isValidCIFOrganizationCode(int code)
Checks whether provided code corresponds to a valid Organization CIF code.static boolean
isValidDNI(java.lang.String value)
Checks whether provided value is a valid DNI (Documento Nacional de Identidad).protected static boolean
isValidDNICode(int code)
Checks whether provided code corresponds to the code of a valid DNI.static boolean
isValidNIE(java.lang.String value)
Checks whether provided value corresponds to a valid NIE (Número de Identificación de Extranjeros).protected static boolean
isValidNIECode(int code)
Checks whether provided code corresponds to a valid NIE (Número de Identificación de Extranjeros).static boolean
isValidNIF(java.lang.String value)
Checks whether provided value is a valid NIF (Número de Identificación Fiscal).protected static boolean
isValidNIFCode(int code)
Checks if provided code corresponds to a valid NIF code.static boolean
isValidNIFMinors(java.lang.String value)
Checks whether provided value corresponds to a valid NIF for minors having less than 14 years old.protected static boolean
isValidNIFMinorsCode(int code)
Checks whether provided code corresponds to a valid NIF for minors having less than 14 years old.static boolean
isValidNIFNonResidents(java.lang.String value)
Checks whether provided value corresponds to a valid non-resident NIF.protected static boolean
isValidNIFNonResidentsCode(int code)
Checks whether provided code corresponds to a valid non-resident NIF.
-
-
-
Field Detail
-
mValRef
private static java.lang.ref.SoftReference<NIFValidator.Validador> mValRef
Reference to the internal validator provided by Ministerio de Hacienda.
-
-
Method Detail
-
isValid
public static boolean isValid(java.lang.String value)
Checks whether provided value is a valid DNI, NIF, NIE or CIF.- Parameters:
value
- DNI, NIF, NIE or CIF to be validated.- Returns:
- true if value is valid, false otherwise.
-
isValidDNI
public static boolean isValidDNI(java.lang.String value)
Checks whether provided value is a valid DNI (Documento Nacional de Identidad).- Parameters:
value
- value to be validated.- Returns:
- true if value is valid, false otherwise.
-
isValidDNICode
protected static boolean isValidDNICode(int code)
Checks whether provided code corresponds to the code of a valid DNI.- Parameters:
code
- code to be validated.- Returns:
- true if code corresponds to a valid DNI, false otherwise.
-
isValidNIF
public static boolean isValidNIF(java.lang.String value)
Checks whether provided value is a valid NIF (Número de Identificación Fiscal).- Parameters:
value
- value to be validated.- Returns:
- true if value is valid, false otherwise.
-
isValidNIFCode
protected static boolean isValidNIFCode(int code)
Checks if provided code corresponds to a valid NIF code.- Parameters:
code
- code to be validated.- Returns:
- true if code corresponds to a valid NIF code, false otherwise.
-
isValidNIFNonResidents
public static boolean isValidNIFNonResidents(java.lang.String value)
Checks whether provided value corresponds to a valid non-resident NIF.- Parameters:
value
- value to be validated.- Returns:
- true if value is valid, false otherwise.
-
isValidNIFNonResidentsCode
protected static boolean isValidNIFNonResidentsCode(int code)
Checks whether provided code corresponds to a valid non-resident NIF.- Parameters:
code
- code to be validated.- Returns:
- true if code corresponds to a valid non-resident NIF, false otherwise.
-
isValidNIFMinors
public static boolean isValidNIFMinors(java.lang.String value)
Checks whether provided value corresponds to a valid NIF for minors having less than 14 years old.- Parameters:
value
- value to be validated.- Returns:
- true if value is valid, false otherwise.
-
isValidNIFMinorsCode
protected static boolean isValidNIFMinorsCode(int code)
Checks whether provided code corresponds to a valid NIF for minors having less than 14 years old.- Parameters:
code
- code to be validated.- Returns:
- true if code corresponds to a valid NIF for minors having less than 14 years old, false otherwise.
-
isValidNIE
public static boolean isValidNIE(java.lang.String value)
Checks whether provided value corresponds to a valid NIE (Número de Identificación de Extranjeros).- Parameters:
value
- value to be validated.- Returns:
- true if value is valid, false otherwise.
-
isValidNIECode
protected static boolean isValidNIECode(int code)
Checks whether provided code corresponds to a valid NIE (Número de Identificación de Extranjeros).- Parameters:
code
- code to be validated.- Returns:
- true if code corresponds to a valid NIE, false otherwise.
-
isValidCIF
public static boolean isValidCIF(java.lang.String value)
Checks whether provided value corresponds to a valid CIF (Código de Identificación Fiscal).- Parameters:
value
- value to be validated.- Returns:
- true if value is valid, false otherwise.
-
isValidCIFCode
public static boolean isValidCIFCode(int code)
Checks whether provided code corresponds to a valid CIF (Código de Identificación Fiscal).- Parameters:
code
- code to be validated.- Returns:
- true if code corresponds to a valid CIF, false otherwise.
-
isValidCIFOrganization
public static boolean isValidCIFOrganization(java.lang.String value)
Checks whether provided value corresponds to a valid Organization CIF.- Parameters:
value
- value to be validated.- Returns:
- true if value is valid, false otherwise.
-
isValidCIFOrganizationCode
public static boolean isValidCIFOrganizationCode(int code)
Checks whether provided code corresponds to a valid Organization CIF code.- Parameters:
code
- code to be validated.- Returns:
- true if code corresponds to a valid Organization CIF, false otherwise.
-
isValidCIFNonResidents
public static boolean isValidCIFNonResidents(java.lang.String value)
Checks whether provided value corresponds to a valid non-resident CIF.- Parameters:
value
- value to be validated.- Returns:
- true if value is valid, false otherwise.
-
isValidCIFNonResidentsCode
public static boolean isValidCIFNonResidentsCode(int code)
Checks whether provided code corresponds to a valid non-resident CIF.- Parameters:
code
- code to be validated.- Returns:
- true if code corresponds to a valid non-resident CIF, false otherwise.
-
getOrCreateValidador
private static NIFValidator.Validador getOrCreateValidador()
Gets or creates singleton instance to validate DNI's, NIF's, CIF's, etc using the library provided by the Ministerio de Hacienda.- Returns:
- internal validator provided by Ministerio de Hacienda.
-
-