Skip to content

Commit

Permalink
Merge pull request #25 from orangedata-official/dm
Browse files Browse the repository at this point in the history
fix: add "none" as valid values to customerContact fields
  • Loading branch information
mashkovtsev committed Nov 9, 2023
2 parents 8504fb0 + ac3cb22 commit 0b7e486
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
8 changes: 8 additions & 0 deletions lib/validation/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,14 @@ module.exports.decimal = function decimal(decimalDigits = '2') {
};
};

module.exports.equals = function equals(comparison) {
return (value) => {
if (!isEmpty(value) && value !== comparison) {
return `Должно быть "${comparison}"`;
}
return false;
};
};

module.exports.oneOf = function oneOf(enumeration) {
return (value) => {
Expand Down
5 changes: 3 additions & 2 deletions lib/validation/schemes.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const {
maxValue,
minLength,
minValue,
equals,
oneOf,
required,
requiredIf,
Expand Down Expand Up @@ -132,7 +133,7 @@ const order = {
payments: [required, arrayOf(payment), maxPaymentsTotal(MAX_MONEY_AMOUNT)],
taxationSystem: [required, integer, oneOf([0, 1, 2, 3, 4, 5])],
})],
customerContact: [maxLength(64), or([email, phone])],
customerContact: [maxLength(64), or([email, phone, equals('none')])],
customer: [maxLength(243)],
customerINN: [inn],
...agent,
Expand Down Expand Up @@ -218,7 +219,7 @@ const correction12 = {
payments: [required, arrayOf(payment), maxPaymentsTotal(MAX_MONEY_AMOUNT)],
taxationSystem: [required, integer, oneOf([0, 1, 2, 3, 4, 5])],
})],
customerContact: [maxLength(64), or([email, phone])],
customerContact: [maxLength(64), or([email, phone, equals('none')])],
correctionType: [required, oneOf([0, 1])],
causeDocumentDate: [required, isIso8601],
causeDocumentNumber: [
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "node-orangedata",
"version": "1.2.6",
"version": "1.2.7",
"description": "Node.js integration for OrangeData service",
"license": "MIT",
"main": "lib",
Expand Down

0 comments on commit 0b7e486

Please sign in to comment.