Skip to content

Commit

Permalink
simplifying logic, same output.
Browse files Browse the repository at this point in the history
  • Loading branch information
ddooley committed Dec 12, 2024
1 parent 430949c commit 8e2c207
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions lib/Validator.js
Original file line number Diff line number Diff line change
Expand Up @@ -236,20 +236,17 @@ class Validator {
);

const validate = (value) => {
if (slotDefinition.required && !value) {
return 'This field is required';
}

if (slotDefinition.value_presence === 'PRESENT' && !value) {
return 'Value is not present';
} else if (slotDefinition.value_presence === 'ABSENT' && value) {
return 'Value is not absent';
}

if (!value) {
if (slotDefinition.required)
return 'This field is required';
if (slotDefinition.value_presence === 'PRESENT')
return 'Value is not present';
return;
}

if (slotDefinition.value_presence === 'ABSENT')
return 'Value is not absent';

let splitValues;
if (slotDefinition.multivalued) {
splitValues = value.split(this.#multivaluedDelimiter);
Expand Down

0 comments on commit 8e2c207

Please sign in to comment.