Skip to content

Commit

Permalink
Se valida que sólo exista el tipo de persona en la primera letra de la
Browse files Browse the repository at this point in the history
cédula
  • Loading branch information
yamelsenih committed Apr 30, 2024
1 parent 44849fa commit 76c07d4
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions core/src/main/java/base/org/erpya/lve/util/LVEUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -142,19 +142,19 @@ public static String processBusinessPartnerValue(Properties context, int clientI
if(value.length() < 6 || value.length() > 11) {
throw new AdempiereException("@LVEInvalidBPValue@");
}
Matcher matcher = Pattern.compile("[^0-9JVEGXjvegx]", Pattern.CASE_INSENSITIVE | Pattern.DOTALL).matcher(value);
// Validate if don't have numbers and allowed characters
Matcher matcher = Pattern.compile("[^0-9JVEGX]", Pattern.CASE_INSENSITIVE | Pattern.DOTALL).matcher(value);
if(matcher.find()) {
// Error
throw new AdempiereException("@LVEInvalidBPValue@");
}
// Validate segments
Matcher matcherforKey = Pattern.compile("^[JVEGXjvegx]+$", Pattern.CASE_INSENSITIVE | Pattern.DOTALL).matcher(value.substring(0, 1));
// Validate the first character allowed
Matcher matcherforKey = Pattern.compile("^[JVEGX]+$", Pattern.CASE_INSENSITIVE | Pattern.DOTALL).matcher(value.substring(0, 1));
if(!matcherforKey.find()) {
// Error
throw new AdempiereException("@LVEInvalidBPValue@");
}
if(!value.substring(1, value.length() -1).matches("[+-]?\\d*(\\.\\d+)?")) {
// Error
// Validate that the rest of string have only numbers
Matcher matcherForNumbers = Pattern.compile("[^0-9]", Pattern.CASE_INSENSITIVE | Pattern.DOTALL).matcher(value.substring(1, value.length()));
if(matcherForNumbers.find()) {
throw new AdempiereException("@LVEInvalidBPValue@");
}
}
Expand Down

0 comments on commit 76c07d4

Please sign in to comment.