Skip to content

Commit

Permalink
Merge pull request #19 from orangedata-official/dm_fix_itemCode_scheme
Browse files Browse the repository at this point in the history
fix: itemCode validation schema
  • Loading branch information
mashkovtsev committed Nov 3, 2023
2 parents 8024f39 + 6d8fad7 commit 8504fb0
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 8 deletions.
4 changes: 4 additions & 0 deletions lib/ItemCode.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,13 @@ class ItemCode {
constructor(order) {
this.id = order.id;
this.inn = order.inn;

if (order.group) this.group = order.group;
if (order.key) this.key = order.key;
if (order.callbackUrl) this.callbackUrl = order.callbackUrl;
if (order.meta) this.meta = order.meta;
if (order.ignoreItemCodeCheck) this.ignoreItemCodeCheck = order.ignoreItemCodeCheck;

this.content = {
plannedStatus: order.plannedStatus,
itemCode: order.itemCode,
Expand Down
2 changes: 1 addition & 1 deletion lib/errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const ORANGE_API_ERRORS = {
401: 'Клиентский сертификат не прошел проверку',
409: 'Чек с данным идентификатором уже был создан в системе',
400: 'Некорректный запрос',
503: 'Очередь документов переполнена, в ответе возвращается хидер Retry-After с таймаутом в секундах',
503: 'Очередь документов переполнена, повторите попытку позже',
};

class OrangeDataError extends Error {
Expand Down
22 changes: 15 additions & 7 deletions lib/validation/schemes.js
Original file line number Diff line number Diff line change
Expand Up @@ -264,14 +264,22 @@ const correction12 = {
};

const itemCode = {
plannedStatus: [required, integer, minValue(0), maxValue(256)],
itemCode: [required, maxLength(223)],
quantityMeasurementUnit: [integer, minValue(0), maxValue(255)],
quantity: [decimal(6)],
fractionalQuantity: [createValidator({
numerator: [integer],
denominator: [integer],
id: [required, maxLength(64)],
inn: [required, inn],
group: [maxLength(32)],
key: [maxLength(32)],
content: [createValidator({
plannedStatus: [required, integer, minValue(0), maxValue(256)],
itemCode: [required, maxLength(223)],
quantityMeasurementUnit: [integer, minValue(0), maxValue(255)],
quantity: [decimal(6)],
fractionalQuantity: [createValidator({
numerator: [integer],
denominator: [integer],
})],
})],
callbackUrl: [maxLength(1024)],
meta: [maxLength(128)],
};

module.exports.serviceOptions = serviceOptions;
Expand Down

0 comments on commit 8504fb0

Please sign in to comment.