opf-validator 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +143 -0
- package/dist/consent/index.d.ts +9 -0
- package/dist/consent/index.d.ts.map +1 -0
- package/dist/consent/index.js +12 -0
- package/dist/consent/index.js.map +1 -0
- package/dist/consent/successResponses/index.d.ts +89 -0
- package/dist/consent/successResponses/index.d.ts.map +1 -0
- package/dist/consent/successResponses/index.js +6 -0
- package/dist/consent/successResponses/index.js.map +1 -0
- package/dist/consent/validators/createConsent.d.ts +31 -0
- package/dist/consent/validators/createConsent.d.ts.map +1 -0
- package/dist/consent/validators/createConsent.js +205 -0
- package/dist/consent/validators/createConsent.js.map +1 -0
- package/dist/consent/validators/createConsentExtensions.d.ts +33 -0
- package/dist/consent/validators/createConsentExtensions.d.ts.map +1 -0
- package/dist/consent/validators/createConsentExtensions.js +193 -0
- package/dist/consent/validators/createConsentExtensions.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +60 -0
- package/dist/index.js.map +1 -0
- package/dist/payments/index.d.ts +11 -0
- package/dist/payments/index.d.ts.map +1 -0
- package/dist/payments/index.js +18 -0
- package/dist/payments/index.js.map +1 -0
- package/dist/payments/successResponses/index.d.ts +129 -0
- package/dist/payments/successResponses/index.d.ts.map +1 -0
- package/dist/payments/successResponses/index.js +6 -0
- package/dist/payments/successResponses/index.js.map +1 -0
- package/dist/payments/validators/createPaymentConsent.d.ts +66 -0
- package/dist/payments/validators/createPaymentConsent.d.ts.map +1 -0
- package/dist/payments/validators/createPaymentConsent.js +508 -0
- package/dist/payments/validators/createPaymentConsent.js.map +1 -0
- package/dist/payments/validators/createPixPayment.d.ts +35 -0
- package/dist/payments/validators/createPixPayment.d.ts.map +1 -0
- package/dist/payments/validators/createPixPayment.js +342 -0
- package/dist/payments/validators/createPixPayment.js.map +1 -0
- package/dist/payments/validators/patchPixPayment.d.ts +40 -0
- package/dist/payments/validators/patchPixPayment.d.ts.map +1 -0
- package/dist/payments/validators/patchPixPayment.js +191 -0
- package/dist/payments/validators/patchPixPayment.js.map +1 -0
- package/dist/recurring-payments/index.d.ts +13 -0
- package/dist/recurring-payments/index.d.ts.map +1 -0
- package/dist/recurring-payments/index.js +17 -0
- package/dist/recurring-payments/index.js.map +1 -0
- package/dist/recurring-payments/successResponses/index.d.ts +175 -0
- package/dist/recurring-payments/successResponses/index.d.ts.map +1 -0
- package/dist/recurring-payments/successResponses/index.js +6 -0
- package/dist/recurring-payments/successResponses/index.js.map +1 -0
- package/dist/recurring-payments/validators/createRecurringConsent.d.ts +96 -0
- package/dist/recurring-payments/validators/createRecurringConsent.d.ts.map +1 -0
- package/dist/recurring-payments/validators/createRecurringConsent.js +663 -0
- package/dist/recurring-payments/validators/createRecurringConsent.js.map +1 -0
- package/dist/recurring-payments/validators/createRecurringRetryPixPayment.d.ts +19 -0
- package/dist/recurring-payments/validators/createRecurringRetryPixPayment.d.ts.map +1 -0
- package/dist/recurring-payments/validators/createRecurringRetryPixPayment.js +41 -0
- package/dist/recurring-payments/validators/createRecurringRetryPixPayment.js.map +1 -0
- package/dist/recurring-payments/validators/patchPixPayment.d.ts +38 -0
- package/dist/recurring-payments/validators/patchPixPayment.d.ts.map +1 -0
- package/dist/recurring-payments/validators/patchPixPayment.js +123 -0
- package/dist/recurring-payments/validators/patchPixPayment.js.map +1 -0
- package/dist/recurring-payments/validators/patchRecurringConsent.d.ts +87 -0
- package/dist/recurring-payments/validators/patchRecurringConsent.d.ts.map +1 -0
- package/dist/recurring-payments/validators/patchRecurringConsent.js +555 -0
- package/dist/recurring-payments/validators/patchRecurringConsent.js.map +1 -0
- package/dist/utils/openFinanceErrors.d.ts +84 -0
- package/dist/utils/openFinanceErrors.d.ts.map +1 -0
- package/dist/utils/openFinanceErrors.js +85 -0
- package/dist/utils/openFinanceErrors.js.map +1 -0
- package/dist/utils/paymentErrors.d.ts +9 -0
- package/dist/utils/paymentErrors.d.ts.map +1 -0
- package/dist/utils/paymentErrors.js +13 -0
- package/dist/utils/paymentErrors.js.map +1 -0
- package/dist/utils/successResponses.d.ts +52 -0
- package/dist/utils/successResponses.d.ts.map +1 -0
- package/dist/utils/successResponses.js +6 -0
- package/dist/utils/successResponses.js.map +1 -0
- package/dist/utils/validateHeaderParameters.d.ts +51 -0
- package/dist/utils/validateHeaderParameters.d.ts.map +1 -0
- package/dist/utils/validateHeaderParameters.js +142 -0
- package/dist/utils/validateHeaderParameters.js.map +1 -0
- package/dist/utils/validationHelpers.d.ts +89 -0
- package/dist/utils/validationHelpers.d.ts.map +1 -0
- package/dist/utils/validationHelpers.js +376 -0
- package/dist/utils/validationHelpers.js.map +1 -0
- package/package.json +20 -0
|
@@ -0,0 +1,663 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Validações para CreateRecurringConsent
|
|
4
|
+
* Segue as regras especificadas no Open Finance Brasil - API de Pagamentos Automáticos
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.validateCreateRecurringConsent = validateCreateRecurringConsent;
|
|
8
|
+
const openFinanceErrors_1 = require("../../utils/openFinanceErrors");
|
|
9
|
+
/**
|
|
10
|
+
* Tipos de documento válidos
|
|
11
|
+
*/
|
|
12
|
+
const VALID_DOCUMENT_TYPES = ["CPF", "CNPJ"];
|
|
13
|
+
/**
|
|
14
|
+
* Tipos de conta válidos para consentimentos
|
|
15
|
+
*/
|
|
16
|
+
const VALID_ACCOUNT_TYPES = ["CACC", "SVGS", "TRAN"];
|
|
17
|
+
/**
|
|
18
|
+
* Intervalos válidos para Pix Automático
|
|
19
|
+
*/
|
|
20
|
+
const VALID_INTERVALS = ["SEMANAL", "MENSAL", "ANUAL", "SEMESTRAL", "TRIMESTRAL"];
|
|
21
|
+
/**
|
|
22
|
+
* Tipos de pessoa válidos
|
|
23
|
+
*/
|
|
24
|
+
const VALID_PERSON_TYPES = ["PESSOA_NATURAL", "PESSOA_JURIDICA"];
|
|
25
|
+
/**
|
|
26
|
+
* Valida o payload de criação de consentimento de pagamento recorrente
|
|
27
|
+
*/
|
|
28
|
+
function validateCreateRecurringConsent(payload) {
|
|
29
|
+
const errors = [];
|
|
30
|
+
// Validação: data deve existir
|
|
31
|
+
if (!payload.data) {
|
|
32
|
+
errors.push(openFinanceErrors_1.CommonErrors.PARAMETRO_NAO_INFORMADO("data"));
|
|
33
|
+
return { isValid: false, errors };
|
|
34
|
+
}
|
|
35
|
+
const data = payload.data;
|
|
36
|
+
// Validação: loggedUser é obrigatório
|
|
37
|
+
if (!data.loggedUser) {
|
|
38
|
+
errors.push(openFinanceErrors_1.CommonErrors.PARAMETRO_NAO_INFORMADO("loggedUser"));
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
const loggedUserErrors = validateLoggedUser(data.loggedUser);
|
|
42
|
+
errors.push(...loggedUserErrors);
|
|
43
|
+
}
|
|
44
|
+
// Validação: businessEntity (opcional, mas se presente deve ser válida)
|
|
45
|
+
if (data.businessEntity) {
|
|
46
|
+
const businessEntityErrors = validateBusinessEntity(data.businessEntity);
|
|
47
|
+
errors.push(...businessEntityErrors);
|
|
48
|
+
}
|
|
49
|
+
// Validação: creditors é obrigatório
|
|
50
|
+
if (!data.creditors) {
|
|
51
|
+
errors.push(openFinanceErrors_1.CommonErrors.PARAMETRO_NAO_INFORMADO("creditors"));
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
const creditorsErrors = validateCreditors(data.creditors);
|
|
55
|
+
errors.push(...creditorsErrors);
|
|
56
|
+
}
|
|
57
|
+
// Validação: recurringConfiguration é obrigatório
|
|
58
|
+
if (!data.recurringConfiguration) {
|
|
59
|
+
errors.push(openFinanceErrors_1.CommonErrors.PARAMETRO_NAO_INFORMADO("recurringConfiguration"));
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
const recurringConfigErrors = validateRecurringConfiguration(data.recurringConfiguration);
|
|
63
|
+
errors.push(...recurringConfigErrors);
|
|
64
|
+
}
|
|
65
|
+
// Validação: expirationDateTime (opcional)
|
|
66
|
+
if (data.expirationDateTime) {
|
|
67
|
+
const expirationErrors = validateExpirationDateTime(data.expirationDateTime, data.recurringConfiguration);
|
|
68
|
+
errors.push(...expirationErrors);
|
|
69
|
+
}
|
|
70
|
+
// Validação: additionalInformation (opcional)
|
|
71
|
+
if (data.additionalInformation) {
|
|
72
|
+
const additionalInfoErrors = validateAdditionalInformation(data.additionalInformation);
|
|
73
|
+
errors.push(...additionalInfoErrors);
|
|
74
|
+
}
|
|
75
|
+
// Validação: debtorAccount (opcional)
|
|
76
|
+
if (data.debtorAccount) {
|
|
77
|
+
const debtorAccountErrors = validateDebtorAccount(data.debtorAccount);
|
|
78
|
+
errors.push(...debtorAccountErrors);
|
|
79
|
+
}
|
|
80
|
+
// Validação: journey (opcional)
|
|
81
|
+
if (data.journey) {
|
|
82
|
+
const journeyErrors = validateJourney(data.journey);
|
|
83
|
+
errors.push(...journeyErrors);
|
|
84
|
+
}
|
|
85
|
+
return {
|
|
86
|
+
isValid: errors.length === 0,
|
|
87
|
+
errors,
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Valida LoggedUser
|
|
92
|
+
*/
|
|
93
|
+
function validateLoggedUser(loggedUser) {
|
|
94
|
+
const errors = [];
|
|
95
|
+
if (typeof loggedUser !== "object" || loggedUser === null) {
|
|
96
|
+
errors.push(openFinanceErrors_1.CommonErrors.PARAMETRO_INVALIDO("loggedUser", "Deve ser um objeto"));
|
|
97
|
+
return errors;
|
|
98
|
+
}
|
|
99
|
+
if (!loggedUser.document) {
|
|
100
|
+
errors.push(openFinanceErrors_1.CommonErrors.PARAMETRO_NAO_INFORMADO("loggedUser.document"));
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
const documentErrors = validateLoggedUserDocument(loggedUser.document);
|
|
104
|
+
errors.push(...documentErrors);
|
|
105
|
+
}
|
|
106
|
+
return errors;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Valida documento do LoggedUser
|
|
110
|
+
*/
|
|
111
|
+
function validateLoggedUserDocument(document) {
|
|
112
|
+
const errors = [];
|
|
113
|
+
if (typeof document !== "object" || document === null) {
|
|
114
|
+
errors.push(openFinanceErrors_1.CommonErrors.PARAMETRO_INVALIDO("loggedUser.document", "Deve ser um objeto"));
|
|
115
|
+
return errors;
|
|
116
|
+
}
|
|
117
|
+
// identification é obrigatório
|
|
118
|
+
if (!document.identification) {
|
|
119
|
+
errors.push(openFinanceErrors_1.CommonErrors.PARAMETRO_NAO_INFORMADO("loggedUser.document.identification"));
|
|
120
|
+
}
|
|
121
|
+
else if (typeof document.identification !== "string") {
|
|
122
|
+
errors.push(openFinanceErrors_1.CommonErrors.PARAMETRO_INVALIDO("loggedUser.document.identification", "Deve ser uma string"));
|
|
123
|
+
}
|
|
124
|
+
else if (document.identification.length > 11) {
|
|
125
|
+
errors.push(openFinanceErrors_1.CommonErrors.PARAMETRO_INVALIDO("loggedUser.document.identification", "CPF deve ter no máximo 11 dígitos"));
|
|
126
|
+
}
|
|
127
|
+
else if (!/^\d{11}$/.test(document.identification)) {
|
|
128
|
+
errors.push(openFinanceErrors_1.CommonErrors.PARAMETRO_INVALIDO("loggedUser.document.identification", "CPF deve conter apenas dígitos"));
|
|
129
|
+
}
|
|
130
|
+
// rel é obrigatório
|
|
131
|
+
if (!document.rel) {
|
|
132
|
+
errors.push(openFinanceErrors_1.CommonErrors.PARAMETRO_NAO_INFORMADO("loggedUser.document.rel"));
|
|
133
|
+
}
|
|
134
|
+
else if (document.rel !== "CPF") {
|
|
135
|
+
errors.push(openFinanceErrors_1.CommonErrors.PARAMETRO_INVALIDO("loggedUser.document.rel", "Deve ser 'CPF' para usuário logado"));
|
|
136
|
+
}
|
|
137
|
+
return errors;
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Valida BusinessEntity
|
|
141
|
+
*/
|
|
142
|
+
function validateBusinessEntity(businessEntity) {
|
|
143
|
+
const errors = [];
|
|
144
|
+
if (typeof businessEntity !== "object" || businessEntity === null) {
|
|
145
|
+
errors.push(openFinanceErrors_1.CommonErrors.PARAMETRO_INVALIDO("businessEntity", "Deve ser um objeto"));
|
|
146
|
+
return errors;
|
|
147
|
+
}
|
|
148
|
+
if (!businessEntity.document) {
|
|
149
|
+
errors.push(openFinanceErrors_1.CommonErrors.PARAMETRO_NAO_INFORMADO("businessEntity.document"));
|
|
150
|
+
}
|
|
151
|
+
else {
|
|
152
|
+
const documentErrors = validateBusinessEntityDocument(businessEntity.document);
|
|
153
|
+
errors.push(...documentErrors);
|
|
154
|
+
}
|
|
155
|
+
return errors;
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Valida documento de BusinessEntity
|
|
159
|
+
*/
|
|
160
|
+
function validateBusinessEntityDocument(document) {
|
|
161
|
+
const errors = [];
|
|
162
|
+
if (typeof document !== "object" || document === null) {
|
|
163
|
+
errors.push(openFinanceErrors_1.CommonErrors.PARAMETRO_INVALIDO("businessEntity.document", "Deve ser um objeto"));
|
|
164
|
+
return errors;
|
|
165
|
+
}
|
|
166
|
+
// identification é obrigatório
|
|
167
|
+
if (!document.identification) {
|
|
168
|
+
errors.push(openFinanceErrors_1.CommonErrors.PARAMETRO_NAO_INFORMADO("businessEntity.document.identification"));
|
|
169
|
+
}
|
|
170
|
+
else if (typeof document.identification !== "string") {
|
|
171
|
+
errors.push(openFinanceErrors_1.CommonErrors.PARAMETRO_INVALIDO("businessEntity.document.identification", "Deve ser uma string"));
|
|
172
|
+
}
|
|
173
|
+
else if (!/^[0-9A-Z]{12}[0-9]{2}$/.test(document.identification)) {
|
|
174
|
+
errors.push(openFinanceErrors_1.CommonErrors.PARAMETRO_INVALIDO("businessEntity.document.identification", "CNPJ deve ter 14 caracteres no formato esperado"));
|
|
175
|
+
}
|
|
176
|
+
// rel é obrigatório
|
|
177
|
+
if (!document.rel) {
|
|
178
|
+
errors.push(openFinanceErrors_1.CommonErrors.PARAMETRO_NAO_INFORMADO("businessEntity.document.rel"));
|
|
179
|
+
}
|
|
180
|
+
else if (document.rel !== "CNPJ") {
|
|
181
|
+
errors.push(openFinanceErrors_1.CommonErrors.PARAMETRO_INVALIDO("businessEntity.document.rel", "Deve ser 'CNPJ' para entidade de negócio"));
|
|
182
|
+
}
|
|
183
|
+
return errors;
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Valida array de creditors (recebedores)
|
|
187
|
+
*/
|
|
188
|
+
function validateCreditors(creditors) {
|
|
189
|
+
const errors = [];
|
|
190
|
+
if (!Array.isArray(creditors)) {
|
|
191
|
+
errors.push(openFinanceErrors_1.CommonErrors.PARAMETRO_INVALIDO("creditors", "Deve ser um array"));
|
|
192
|
+
return errors;
|
|
193
|
+
}
|
|
194
|
+
if (creditors.length === 0) {
|
|
195
|
+
errors.push((0, openFinanceErrors_1.createError)("PARAMETRO_INVALIDO", "Parâmetro inválido.", "Array de creditors deve conter pelo menos um item"));
|
|
196
|
+
return errors;
|
|
197
|
+
}
|
|
198
|
+
creditors.forEach((creditor, index) => {
|
|
199
|
+
const creditorErrors = validateCreditor(creditor);
|
|
200
|
+
creditorErrors.forEach((error) => {
|
|
201
|
+
errors.push({
|
|
202
|
+
...error,
|
|
203
|
+
detail: `creditors[${index}]: ${error.detail}`,
|
|
204
|
+
});
|
|
205
|
+
});
|
|
206
|
+
});
|
|
207
|
+
return errors;
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* Valida um creditor individual
|
|
211
|
+
*/
|
|
212
|
+
function validateCreditor(creditor) {
|
|
213
|
+
const errors = [];
|
|
214
|
+
if (typeof creditor !== "object" || creditor === null) {
|
|
215
|
+
errors.push(openFinanceErrors_1.CommonErrors.PARAMETRO_INVALIDO("creditor", "Deve ser um objeto"));
|
|
216
|
+
return errors;
|
|
217
|
+
}
|
|
218
|
+
// personType é obrigatório
|
|
219
|
+
if (!creditor.personType) {
|
|
220
|
+
errors.push(openFinanceErrors_1.CommonErrors.PARAMETRO_NAO_INFORMADO("personType"));
|
|
221
|
+
}
|
|
222
|
+
else if (!VALID_PERSON_TYPES.includes(creditor.personType)) {
|
|
223
|
+
errors.push(openFinanceErrors_1.CommonErrors.PARAMETRO_INVALIDO("personType", `Deve ser um dos: ${VALID_PERSON_TYPES.join(", ")}`));
|
|
224
|
+
}
|
|
225
|
+
// cpfCnpj é obrigatório
|
|
226
|
+
if (!creditor.cpfCnpj) {
|
|
227
|
+
errors.push(openFinanceErrors_1.CommonErrors.PARAMETRO_NAO_INFORMADO("cpfCnpj"));
|
|
228
|
+
}
|
|
229
|
+
else if (typeof creditor.cpfCnpj !== "string") {
|
|
230
|
+
errors.push(openFinanceErrors_1.CommonErrors.PARAMETRO_INVALIDO("cpfCnpj", "Deve ser uma string"));
|
|
231
|
+
}
|
|
232
|
+
else {
|
|
233
|
+
// Validar formato de CPF ou CNPJ
|
|
234
|
+
const isCpf = /^\d{11}$/.test(creditor.cpfCnpj);
|
|
235
|
+
const isCnpj = /^[0-9A-Z]{12}[0-9]{2}$/.test(creditor.cpfCnpj);
|
|
236
|
+
if (!isCpf && !isCnpj) {
|
|
237
|
+
errors.push(openFinanceErrors_1.CommonErrors.PARAMETRO_INVALIDO("cpfCnpj", "Deve ser um CPF (11 dígitos) ou CNPJ (14 caracteres)"));
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
// name é obrigatório
|
|
241
|
+
if (!creditor.name) {
|
|
242
|
+
errors.push(openFinanceErrors_1.CommonErrors.PARAMETRO_NAO_INFORMADO("name"));
|
|
243
|
+
}
|
|
244
|
+
else if (typeof creditor.name !== "string") {
|
|
245
|
+
errors.push(openFinanceErrors_1.CommonErrors.PARAMETRO_INVALIDO("name", "Deve ser uma string"));
|
|
246
|
+
}
|
|
247
|
+
else if (creditor.name.length > 120) {
|
|
248
|
+
errors.push(openFinanceErrors_1.CommonErrors.PARAMETRO_INVALIDO("name", "Deve ter no máximo 120 caracteres"));
|
|
249
|
+
}
|
|
250
|
+
return errors;
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* Valida recurringConfiguration
|
|
254
|
+
*/
|
|
255
|
+
function validateRecurringConfiguration(config) {
|
|
256
|
+
const errors = [];
|
|
257
|
+
if (typeof config !== "object" || config === null) {
|
|
258
|
+
errors.push(openFinanceErrors_1.CommonErrors.PARAMETRO_INVALIDO("recurringConfiguration", "Deve ser um objeto"));
|
|
259
|
+
return errors;
|
|
260
|
+
}
|
|
261
|
+
// Validar que apenas um dos tipos está presente
|
|
262
|
+
const hasAutomatic = !!config.automatic;
|
|
263
|
+
const hasSweeping = !!config.sweeping;
|
|
264
|
+
const hasVrp = !!config.vrp;
|
|
265
|
+
const configCount = [hasAutomatic, hasSweeping, hasVrp].filter(Boolean).length;
|
|
266
|
+
if (configCount !== 1) {
|
|
267
|
+
errors.push((0, openFinanceErrors_1.createError)("PARAMETRO_INVALIDO", "Parâmetro inválido.", "recurringConfiguration deve conter exatamente um dos: automatic, sweeping ou vrp"));
|
|
268
|
+
return errors;
|
|
269
|
+
}
|
|
270
|
+
if (hasAutomatic) {
|
|
271
|
+
const automaticErrors = validateAutomaticConfig(config.automatic);
|
|
272
|
+
errors.push(...automaticErrors);
|
|
273
|
+
}
|
|
274
|
+
if (hasSweeping) {
|
|
275
|
+
const sweepingErrors = validateSweepingConfig(config.sweeping);
|
|
276
|
+
errors.push(...sweepingErrors);
|
|
277
|
+
}
|
|
278
|
+
if (hasVrp) {
|
|
279
|
+
const vrpErrors = validateVrpConfig(config.vrp);
|
|
280
|
+
errors.push(...vrpErrors);
|
|
281
|
+
}
|
|
282
|
+
return errors;
|
|
283
|
+
}
|
|
284
|
+
/**
|
|
285
|
+
* Valida configuração de Pix Automático
|
|
286
|
+
*/
|
|
287
|
+
function validateAutomaticConfig(automatic) {
|
|
288
|
+
const errors = [];
|
|
289
|
+
if (typeof automatic !== "object" || automatic === null) {
|
|
290
|
+
errors.push(openFinanceErrors_1.CommonErrors.PARAMETRO_INVALIDO("automatic", "Deve ser um objeto"));
|
|
291
|
+
return errors;
|
|
292
|
+
}
|
|
293
|
+
// contractId é obrigatório
|
|
294
|
+
if (!automatic.contractId) {
|
|
295
|
+
errors.push(openFinanceErrors_1.CommonErrors.PARAMETRO_NAO_INFORMADO("recurringConfiguration.automatic.contractId"));
|
|
296
|
+
}
|
|
297
|
+
else if (typeof automatic.contractId !== "string") {
|
|
298
|
+
errors.push(openFinanceErrors_1.CommonErrors.PARAMETRO_INVALIDO("contractId", "Deve ser uma string"));
|
|
299
|
+
}
|
|
300
|
+
else if (!/^[a-zA-Z0-9]{1,35}$/.test(automatic.contractId)) {
|
|
301
|
+
errors.push(openFinanceErrors_1.CommonErrors.PARAMETRO_INVALIDO("contractId", "Deve conter de 1 a 35 caracteres alfanuméricos"));
|
|
302
|
+
}
|
|
303
|
+
// interval é obrigatório
|
|
304
|
+
if (!automatic.interval) {
|
|
305
|
+
errors.push(openFinanceErrors_1.CommonErrors.PARAMETRO_NAO_INFORMADO("recurringConfiguration.automatic.interval"));
|
|
306
|
+
}
|
|
307
|
+
else if (!VALID_INTERVALS.includes(automatic.interval)) {
|
|
308
|
+
errors.push(openFinanceErrors_1.CommonErrors.PARAMETRO_INVALIDO("interval", `Deve ser um dos: ${VALID_INTERVALS.join(", ")}`));
|
|
309
|
+
}
|
|
310
|
+
// contractDebtor é obrigatório
|
|
311
|
+
if (!automatic.contractDebtor) {
|
|
312
|
+
errors.push(openFinanceErrors_1.CommonErrors.PARAMETRO_NAO_INFORMADO("recurringConfiguration.automatic.contractDebtor"));
|
|
313
|
+
}
|
|
314
|
+
else {
|
|
315
|
+
const debtorErrors = validateContractDebtor(automatic.contractDebtor);
|
|
316
|
+
errors.push(...debtorErrors);
|
|
317
|
+
}
|
|
318
|
+
// isRetryAccepted é obrigatório
|
|
319
|
+
if (automatic.isRetryAccepted === undefined) {
|
|
320
|
+
errors.push(openFinanceErrors_1.CommonErrors.PARAMETRO_NAO_INFORMADO("recurringConfiguration.automatic.isRetryAccepted"));
|
|
321
|
+
}
|
|
322
|
+
else if (typeof automatic.isRetryAccepted !== "boolean") {
|
|
323
|
+
errors.push(openFinanceErrors_1.CommonErrors.PARAMETRO_INVALIDO("isRetryAccepted", "Deve ser um valor booleano"));
|
|
324
|
+
}
|
|
325
|
+
// referenceStartDate é obrigatório
|
|
326
|
+
if (!automatic.referenceStartDate) {
|
|
327
|
+
errors.push(openFinanceErrors_1.CommonErrors.PARAMETRO_NAO_INFORMADO("recurringConfiguration.automatic.referenceStartDate"));
|
|
328
|
+
}
|
|
329
|
+
else {
|
|
330
|
+
const dateErrors = validateReferenceStartDate(automatic.referenceStartDate);
|
|
331
|
+
errors.push(...dateErrors);
|
|
332
|
+
}
|
|
333
|
+
// fixedAmount e maximumVariableAmount são excludentes
|
|
334
|
+
if (automatic.fixedAmount && automatic.maximumVariableAmount) {
|
|
335
|
+
errors.push((0, openFinanceErrors_1.createError)("PARAMETRO_INVALIDO", "Parâmetro inválido.", "fixedAmount e maximumVariableAmount são excludentes"));
|
|
336
|
+
}
|
|
337
|
+
// Validar fixedAmount se presente
|
|
338
|
+
if (automatic.fixedAmount) {
|
|
339
|
+
const fixedAmountErrors = validateAmount(automatic.fixedAmount, "fixedAmount");
|
|
340
|
+
errors.push(...fixedAmountErrors);
|
|
341
|
+
}
|
|
342
|
+
// Validar maximumVariableAmount se presente
|
|
343
|
+
if (automatic.maximumVariableAmount) {
|
|
344
|
+
const maxAmountErrors = validateAmount(automatic.maximumVariableAmount, "maximumVariableAmount");
|
|
345
|
+
errors.push(...maxAmountErrors);
|
|
346
|
+
// Se maximumVariableAmount está presente, minimumVariableAmount não pode excedê-lo
|
|
347
|
+
if (automatic.minimumVariableAmount) {
|
|
348
|
+
const minAmountErrors = validateAmount(automatic.minimumVariableAmount, "minimumVariableAmount");
|
|
349
|
+
errors.push(...minAmountErrors);
|
|
350
|
+
// Comparar valores
|
|
351
|
+
const maxValue = parseFloat(automatic.maximumVariableAmount);
|
|
352
|
+
const minValue = parseFloat(automatic.minimumVariableAmount);
|
|
353
|
+
if (minValue > maxValue) {
|
|
354
|
+
errors.push((0, openFinanceErrors_1.createError)("DETALHE_PAGAMENTO_INVALIDO", "Detalhe do pagamento inválido.", "minimumVariableAmount não pode ser maior que maximumVariableAmount"));
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
// Validar firstPayment se presente
|
|
359
|
+
if (automatic.firstPayment) {
|
|
360
|
+
const firstPaymentErrors = validateFirstPayment(automatic.firstPayment);
|
|
361
|
+
errors.push(...firstPaymentErrors);
|
|
362
|
+
}
|
|
363
|
+
return errors;
|
|
364
|
+
}
|
|
365
|
+
/**
|
|
366
|
+
* Valida ContractDebtor
|
|
367
|
+
*/
|
|
368
|
+
function validateContractDebtor(debtor) {
|
|
369
|
+
const errors = [];
|
|
370
|
+
if (typeof debtor !== "object" || debtor === null) {
|
|
371
|
+
errors.push(openFinanceErrors_1.CommonErrors.PARAMETRO_INVALIDO("contractDebtor", "Deve ser um objeto"));
|
|
372
|
+
return errors;
|
|
373
|
+
}
|
|
374
|
+
// name é obrigatório
|
|
375
|
+
if (!debtor.name) {
|
|
376
|
+
errors.push(openFinanceErrors_1.CommonErrors.PARAMETRO_NAO_INFORMADO("recurringConfiguration.automatic.contractDebtor.name"));
|
|
377
|
+
}
|
|
378
|
+
else if (typeof debtor.name !== "string") {
|
|
379
|
+
errors.push(openFinanceErrors_1.CommonErrors.PARAMETRO_INVALIDO("name", "Deve ser uma string"));
|
|
380
|
+
}
|
|
381
|
+
else if (debtor.name.length > 120) {
|
|
382
|
+
errors.push(openFinanceErrors_1.CommonErrors.PARAMETRO_INVALIDO("name", "Deve ter no máximo 120 caracteres"));
|
|
383
|
+
}
|
|
384
|
+
// document é obrigatório
|
|
385
|
+
if (!debtor.document) {
|
|
386
|
+
errors.push(openFinanceErrors_1.CommonErrors.PARAMETRO_NAO_INFORMADO("recurringConfiguration.automatic.contractDebtor.document"));
|
|
387
|
+
}
|
|
388
|
+
else {
|
|
389
|
+
const docErrors = validateContractDebtorDocument(debtor.document);
|
|
390
|
+
errors.push(...docErrors);
|
|
391
|
+
}
|
|
392
|
+
return errors;
|
|
393
|
+
}
|
|
394
|
+
/**
|
|
395
|
+
* Valida documento do ContractDebtor
|
|
396
|
+
*/
|
|
397
|
+
function validateContractDebtorDocument(document) {
|
|
398
|
+
const errors = [];
|
|
399
|
+
if (typeof document !== "object" || document === null) {
|
|
400
|
+
errors.push(openFinanceErrors_1.CommonErrors.PARAMETRO_INVALIDO("document", "Deve ser um objeto"));
|
|
401
|
+
return errors;
|
|
402
|
+
}
|
|
403
|
+
// identification é obrigatório
|
|
404
|
+
if (!document.identification) {
|
|
405
|
+
errors.push(openFinanceErrors_1.CommonErrors.PARAMETRO_NAO_INFORMADO("document.identification"));
|
|
406
|
+
}
|
|
407
|
+
else if (!/^(\d{11})|([0-9A-Z]{12}\d{2})$/.test(document.identification)) {
|
|
408
|
+
errors.push(openFinanceErrors_1.CommonErrors.PARAMETRO_INVALIDO("document.identification", "Deve ser um CPF (11 dígitos) ou CNPJ (14 caracteres)"));
|
|
409
|
+
}
|
|
410
|
+
// rel é obrigatório
|
|
411
|
+
if (!document.rel) {
|
|
412
|
+
errors.push(openFinanceErrors_1.CommonErrors.PARAMETRO_NAO_INFORMADO("document.rel"));
|
|
413
|
+
}
|
|
414
|
+
else if (!["CPF", "CNPJ"].includes(document.rel)) {
|
|
415
|
+
errors.push(openFinanceErrors_1.CommonErrors.PARAMETRO_INVALIDO("document.rel", "Deve ser 'CPF' ou 'CNPJ'"));
|
|
416
|
+
}
|
|
417
|
+
return errors;
|
|
418
|
+
}
|
|
419
|
+
/**
|
|
420
|
+
* Valida data de início da recorrência
|
|
421
|
+
*/
|
|
422
|
+
function validateReferenceStartDate(date) {
|
|
423
|
+
const errors = [];
|
|
424
|
+
if (typeof date !== "string") {
|
|
425
|
+
errors.push(openFinanceErrors_1.CommonErrors.PARAMETRO_INVALIDO("referenceStartDate", "Deve ser uma string"));
|
|
426
|
+
return errors;
|
|
427
|
+
}
|
|
428
|
+
const datePattern = /^(\d{4})-(1[0-2]|0?[1-9])-(3[01]|[12][0-9]|0?[1-9])$/;
|
|
429
|
+
if (!datePattern.test(date)) {
|
|
430
|
+
errors.push(openFinanceErrors_1.CommonErrors.PARAMETRO_INVALIDO("referenceStartDate", "Deve estar no formato YYYY-MM-DD"));
|
|
431
|
+
}
|
|
432
|
+
return errors;
|
|
433
|
+
}
|
|
434
|
+
/**
|
|
435
|
+
* Valida valor monetário
|
|
436
|
+
*/
|
|
437
|
+
function validateAmount(amount, fieldName) {
|
|
438
|
+
const errors = [];
|
|
439
|
+
if (typeof amount !== "string") {
|
|
440
|
+
errors.push(openFinanceErrors_1.CommonErrors.PARAMETRO_INVALIDO(fieldName, "Deve ser uma string"));
|
|
441
|
+
return errors;
|
|
442
|
+
}
|
|
443
|
+
const amountPattern = /^(\d{1,16}\.\d{2})$/;
|
|
444
|
+
if (!amountPattern.test(amount)) {
|
|
445
|
+
errors.push(openFinanceErrors_1.CommonErrors.PARAMETRO_INVALIDO(fieldName, "Deve ser um valor monetário no formato 0000000.00"));
|
|
446
|
+
}
|
|
447
|
+
return errors;
|
|
448
|
+
}
|
|
449
|
+
/**
|
|
450
|
+
* Valida FirstPayment
|
|
451
|
+
*/
|
|
452
|
+
function validateFirstPayment(payment) {
|
|
453
|
+
const errors = [];
|
|
454
|
+
if (typeof payment !== "object" || payment === null) {
|
|
455
|
+
errors.push(openFinanceErrors_1.CommonErrors.PARAMETRO_INVALIDO("firstPayment", "Deve ser um objeto"));
|
|
456
|
+
return errors;
|
|
457
|
+
}
|
|
458
|
+
// type é obrigatório
|
|
459
|
+
if (!payment.type) {
|
|
460
|
+
errors.push(openFinanceErrors_1.CommonErrors.PARAMETRO_NAO_INFORMADO("firstPayment.type"));
|
|
461
|
+
}
|
|
462
|
+
else if (payment.type !== "PIX") {
|
|
463
|
+
errors.push(openFinanceErrors_1.CommonErrors.PARAMETRO_INVALIDO("type", "Deve ser 'PIX'"));
|
|
464
|
+
}
|
|
465
|
+
// date é obrigatório
|
|
466
|
+
if (!payment.date) {
|
|
467
|
+
errors.push(openFinanceErrors_1.CommonErrors.PARAMETRO_NAO_INFORMADO("firstPayment.date"));
|
|
468
|
+
}
|
|
469
|
+
else {
|
|
470
|
+
const dateErrors = validateReferenceStartDate(payment.date);
|
|
471
|
+
errors.push(...dateErrors);
|
|
472
|
+
}
|
|
473
|
+
// currency é obrigatório
|
|
474
|
+
if (!payment.currency) {
|
|
475
|
+
errors.push(openFinanceErrors_1.CommonErrors.PARAMETRO_NAO_INFORMADO("firstPayment.currency"));
|
|
476
|
+
}
|
|
477
|
+
else if (payment.currency !== "BRL") {
|
|
478
|
+
errors.push(openFinanceErrors_1.CommonErrors.PARAMETRO_INVALIDO("currency", "Deve ser 'BRL' (Real Brasileiro)"));
|
|
479
|
+
}
|
|
480
|
+
// amount é obrigatório
|
|
481
|
+
if (!payment.amount) {
|
|
482
|
+
errors.push(openFinanceErrors_1.CommonErrors.PARAMETRO_NAO_INFORMADO("firstPayment.amount"));
|
|
483
|
+
}
|
|
484
|
+
else {
|
|
485
|
+
const amountErrors = validateAmount(payment.amount, "amount");
|
|
486
|
+
errors.push(...amountErrors);
|
|
487
|
+
}
|
|
488
|
+
// creditorAccount é obrigatório
|
|
489
|
+
if (!payment.creditorAccount) {
|
|
490
|
+
errors.push(openFinanceErrors_1.CommonErrors.PARAMETRO_NAO_INFORMADO("firstPayment.creditorAccount"));
|
|
491
|
+
}
|
|
492
|
+
else {
|
|
493
|
+
const creditorAccountErrors = validateCreditorAccount(payment.creditorAccount);
|
|
494
|
+
errors.push(...creditorAccountErrors);
|
|
495
|
+
}
|
|
496
|
+
return errors;
|
|
497
|
+
}
|
|
498
|
+
/**
|
|
499
|
+
* Valida conta de crédito
|
|
500
|
+
*/
|
|
501
|
+
function validateCreditorAccount(account) {
|
|
502
|
+
const errors = [];
|
|
503
|
+
if (typeof account !== "object" || account === null) {
|
|
504
|
+
errors.push(openFinanceErrors_1.CommonErrors.PARAMETRO_INVALIDO("creditorAccount", "Deve ser um objeto"));
|
|
505
|
+
return errors;
|
|
506
|
+
}
|
|
507
|
+
// ispb é obrigatório
|
|
508
|
+
if (!account.ispb) {
|
|
509
|
+
errors.push(openFinanceErrors_1.CommonErrors.PARAMETRO_NAO_INFORMADO("creditorAccount.ispb"));
|
|
510
|
+
}
|
|
511
|
+
else if (!/^[0-9A-Z]{8}$/.test(account.ispb)) {
|
|
512
|
+
errors.push(openFinanceErrors_1.CommonErrors.PARAMETRO_INVALIDO("ispb", "Deve ter exatamente 8 caracteres alfanuméricos"));
|
|
513
|
+
}
|
|
514
|
+
// number é obrigatório
|
|
515
|
+
if (!account.number) {
|
|
516
|
+
errors.push(openFinanceErrors_1.CommonErrors.PARAMETRO_NAO_INFORMADO("creditorAccount.number"));
|
|
517
|
+
}
|
|
518
|
+
else if (!/^\d{1,20}$/.test(account.number)) {
|
|
519
|
+
errors.push(openFinanceErrors_1.CommonErrors.PARAMETRO_INVALIDO("number", "Deve ter de 1 a 20 dígitos"));
|
|
520
|
+
}
|
|
521
|
+
// accountType é obrigatório
|
|
522
|
+
if (!account.accountType) {
|
|
523
|
+
errors.push(openFinanceErrors_1.CommonErrors.PARAMETRO_NAO_INFORMADO("creditorAccount.accountType"));
|
|
524
|
+
}
|
|
525
|
+
else if (!VALID_ACCOUNT_TYPES.includes(account.accountType)) {
|
|
526
|
+
errors.push(openFinanceErrors_1.CommonErrors.PARAMETRO_INVALIDO("accountType", `Deve ser um dos: ${VALID_ACCOUNT_TYPES.join(", ")}`));
|
|
527
|
+
}
|
|
528
|
+
// issuer é opcional, mas se presente deve ser válido
|
|
529
|
+
if (account.issuer && !/^\d{1,4}$/.test(account.issuer)) {
|
|
530
|
+
errors.push(openFinanceErrors_1.CommonErrors.PARAMETRO_INVALIDO("issuer", "Deve ter de 1 a 4 dígitos"));
|
|
531
|
+
}
|
|
532
|
+
return errors;
|
|
533
|
+
}
|
|
534
|
+
/**
|
|
535
|
+
* Valida DebtorAccount (opcional)
|
|
536
|
+
*/
|
|
537
|
+
function validateDebtorAccount(account) {
|
|
538
|
+
const errors = [];
|
|
539
|
+
if (typeof account !== "object" || account === null) {
|
|
540
|
+
errors.push(openFinanceErrors_1.CommonErrors.PARAMETRO_INVALIDO("debtorAccount", "Deve ser um objeto"));
|
|
541
|
+
return errors;
|
|
542
|
+
}
|
|
543
|
+
// ispb é obrigatório
|
|
544
|
+
if (!account.ispb) {
|
|
545
|
+
errors.push(openFinanceErrors_1.CommonErrors.PARAMETRO_NAO_INFORMADO("debtorAccount.ispb"));
|
|
546
|
+
}
|
|
547
|
+
else if (!/^[0-9A-Z]{8}$/.test(account.ispb)) {
|
|
548
|
+
errors.push(openFinanceErrors_1.CommonErrors.PARAMETRO_INVALIDO("ispb", "Deve ter exatamente 8 caracteres alfanuméricos"));
|
|
549
|
+
}
|
|
550
|
+
// number é obrigatório
|
|
551
|
+
if (!account.number) {
|
|
552
|
+
errors.push(openFinanceErrors_1.CommonErrors.PARAMETRO_NAO_INFORMADO("debtorAccount.number"));
|
|
553
|
+
}
|
|
554
|
+
else if (!/^\d{1,20}$/.test(account.number)) {
|
|
555
|
+
errors.push(openFinanceErrors_1.CommonErrors.PARAMETRO_INVALIDO("number", "Deve ter de 1 a 20 dígitos"));
|
|
556
|
+
}
|
|
557
|
+
// accountType é obrigatório
|
|
558
|
+
if (!account.accountType) {
|
|
559
|
+
errors.push(openFinanceErrors_1.CommonErrors.PARAMETRO_NAO_INFORMADO("debtorAccount.accountType"));
|
|
560
|
+
}
|
|
561
|
+
else if (!VALID_ACCOUNT_TYPES.includes(account.accountType)) {
|
|
562
|
+
errors.push(openFinanceErrors_1.CommonErrors.PARAMETRO_INVALIDO("accountType", `Deve ser um dos: ${VALID_ACCOUNT_TYPES.join(", ")}`));
|
|
563
|
+
}
|
|
564
|
+
// issuer é opcional, mas se presente deve ser válido
|
|
565
|
+
if (account.issuer && !/^\d{1,4}$/.test(account.issuer)) {
|
|
566
|
+
errors.push(openFinanceErrors_1.CommonErrors.PARAMETRO_INVALIDO("issuer", "Deve ter de 1 a 4 dígitos"));
|
|
567
|
+
}
|
|
568
|
+
return errors;
|
|
569
|
+
}
|
|
570
|
+
/**
|
|
571
|
+
* Valida expirationDateTime
|
|
572
|
+
* [Restrição] Caso o consentimento seja para Pix Automático, o horário de expiração do consentimento precisa ser às 23:59:59 (UTC).
|
|
573
|
+
*/
|
|
574
|
+
function validateExpirationDateTime(expirationDateTime, recurringConfiguration) {
|
|
575
|
+
const errors = [];
|
|
576
|
+
if (typeof expirationDateTime !== "string") {
|
|
577
|
+
errors.push(openFinanceErrors_1.CommonErrors.PARAMETRO_INVALIDO("expirationDateTime", "Deve ser uma string"));
|
|
578
|
+
return errors;
|
|
579
|
+
}
|
|
580
|
+
const rfc3339Pattern = /^(\d{4})-(1[0-2]|0?[1-9])-(3[01]|[12][0-9]|0?[1-9])T(?:[01]\d|2[0123]):(?:[012345]\d):(?:[012345]\d)Z$/;
|
|
581
|
+
if (!rfc3339Pattern.test(expirationDateTime)) {
|
|
582
|
+
errors.push((0, openFinanceErrors_1.createError)("PARAMETRO_INVALIDO", "Parâmetro inválido.", "expirationDateTime deve estar no formato RFC-3339 com timezone UTC (YYYY-MM-DDTHH:mm:ssZ)"));
|
|
583
|
+
return errors;
|
|
584
|
+
}
|
|
585
|
+
// Validar que é Pix Automático
|
|
586
|
+
if (recurringConfiguration?.automatic) {
|
|
587
|
+
// Extrair hora do expirationDateTime
|
|
588
|
+
const hourMatch = expirationDateTime.match(/T(\d{2}):(\d{2}):(\d{2})Z$/);
|
|
589
|
+
if (hourMatch) {
|
|
590
|
+
const hour = hourMatch[1];
|
|
591
|
+
const minute = hourMatch[2];
|
|
592
|
+
const second = hourMatch[3];
|
|
593
|
+
if (hour !== "23" || minute !== "59" || second !== "59") {
|
|
594
|
+
errors.push((0, openFinanceErrors_1.createError)("DATA_EXPIRACAO_INVALIDA", "Nova data para expiração do consentimento é inválida.", "Para Pix Automático, o horário de expiração deve ser às 23:59:59 (UTC)"));
|
|
595
|
+
}
|
|
596
|
+
}
|
|
597
|
+
}
|
|
598
|
+
return errors;
|
|
599
|
+
}
|
|
600
|
+
/**
|
|
601
|
+
* Valida additionalInformation
|
|
602
|
+
*/
|
|
603
|
+
function validateAdditionalInformation(info) {
|
|
604
|
+
const errors = [];
|
|
605
|
+
if (typeof info !== "string") {
|
|
606
|
+
errors.push(openFinanceErrors_1.CommonErrors.PARAMETRO_INVALIDO("additionalInformation", "Deve ser uma string"));
|
|
607
|
+
}
|
|
608
|
+
else if (info.length > 140) {
|
|
609
|
+
errors.push(openFinanceErrors_1.CommonErrors.PARAMETRO_INVALIDO("additionalInformation", "Deve ter no máximo 140 caracteres"));
|
|
610
|
+
}
|
|
611
|
+
return errors;
|
|
612
|
+
}
|
|
613
|
+
/**
|
|
614
|
+
* Valida Journey
|
|
615
|
+
*/
|
|
616
|
+
function validateJourney(journey) {
|
|
617
|
+
const errors = [];
|
|
618
|
+
if (typeof journey !== "object" || journey === null) {
|
|
619
|
+
errors.push(openFinanceErrors_1.CommonErrors.PARAMETRO_INVALIDO("journey", "Deve ser um objeto"));
|
|
620
|
+
return errors;
|
|
621
|
+
}
|
|
622
|
+
// isLinked é obrigatório
|
|
623
|
+
if (journey.isLinked === undefined) {
|
|
624
|
+
errors.push(openFinanceErrors_1.CommonErrors.PARAMETRO_NAO_INFORMADO("journey.isLinked"));
|
|
625
|
+
}
|
|
626
|
+
else if (typeof journey.isLinked !== "boolean") {
|
|
627
|
+
errors.push(openFinanceErrors_1.CommonErrors.PARAMETRO_INVALIDO("isLinked", "Deve ser um valor booleano"));
|
|
628
|
+
}
|
|
629
|
+
// linkId é obrigatório
|
|
630
|
+
if (!journey.linkId) {
|
|
631
|
+
errors.push(openFinanceErrors_1.CommonErrors.PARAMETRO_NAO_INFORMADO("journey.linkId"));
|
|
632
|
+
}
|
|
633
|
+
else if (typeof journey.linkId !== "string") {
|
|
634
|
+
errors.push(openFinanceErrors_1.CommonErrors.PARAMETRO_INVALIDO("linkId", "Deve ser uma string"));
|
|
635
|
+
}
|
|
636
|
+
else if (journey.linkId.length > 256) {
|
|
637
|
+
errors.push(openFinanceErrors_1.CommonErrors.PARAMETRO_INVALIDO("linkId", "Deve ter no máximo 256 caracteres"));
|
|
638
|
+
}
|
|
639
|
+
return errors;
|
|
640
|
+
}
|
|
641
|
+
/**
|
|
642
|
+
* Valida configuração de Sweeping (Transferências Inteligentes)
|
|
643
|
+
*/
|
|
644
|
+
function validateSweepingConfig(sweeping) {
|
|
645
|
+
const errors = [];
|
|
646
|
+
// Por enquanto, apenas validar estrutura básica
|
|
647
|
+
if (typeof sweeping !== "object" || sweeping === null) {
|
|
648
|
+
errors.push(openFinanceErrors_1.CommonErrors.PARAMETRO_INVALIDO("sweeping", "Deve ser um objeto"));
|
|
649
|
+
}
|
|
650
|
+
return errors;
|
|
651
|
+
}
|
|
652
|
+
/**
|
|
653
|
+
* Valida configuração de VRP
|
|
654
|
+
*/
|
|
655
|
+
function validateVrpConfig(vrp) {
|
|
656
|
+
const errors = [];
|
|
657
|
+
// Por enquanto, apenas validar estrutura básica
|
|
658
|
+
if (typeof vrp !== "object" || vrp === null) {
|
|
659
|
+
errors.push(openFinanceErrors_1.CommonErrors.PARAMETRO_INVALIDO("vrp", "Deve ser um objeto"));
|
|
660
|
+
}
|
|
661
|
+
return errors;
|
|
662
|
+
}
|
|
663
|
+
//# sourceMappingURL=createRecurringConsent.js.map
|