Skip to content

Commit

Permalink
more small chenges in SireneValidator
Browse files Browse the repository at this point in the history
  • Loading branch information
homebeaver committed Oct 10, 2024
1 parent c4c2401 commit 79709d3
Showing 1 changed file with 5 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import org.apache.commons.validator.routines.checkdigit.LuhnCheckDigit;

/**
* SIRENE (FR System Information et Repertoire des Entreprise et des Etablissements) Validator.
* SIRENE (French System Information et Repertoire des Entreprise et des Etablissements) Validator.
*
* <p>
* International Code Designator, ICD : 0002 for SIRENE
Expand Down Expand Up @@ -106,15 +106,14 @@ public boolean isValid(final String code) {
if (GenericValidator.isBlankOrNull(code)) {
return false;
}

String id = code.trim();
if (id.length() != SIREN_CODE_LEN && id.length() != SIRET_CODE_LEN) {
return false;
}

// format check:
if (!formatValidator.validator.isValid(id)) return false;

if (!formatValidator.validator.isValid(id)) {
return false;
}
if (id.length() == SIREN_CODE_LEN) {
return LuhnCheckDigit.LUHN_CHECK_DIGIT.isValid(id);
}
Expand All @@ -124,7 +123,7 @@ public boolean isValid(final String code) {
}
return false;
}

// check SIRET:
return LuhnCheckDigit.LUHN_CHECK_DIGIT.isValid(id);
}

Expand Down

0 comments on commit 79709d3

Please sign in to comment.