@77sol-lab/form-schemas 1.7.0 → 3.0.0
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/{chunk-HMC73HBG.mjs → chunk-4T4DDJJZ.mjs} +7 -7
- package/{chunk-DIYEI2PA.mjs → chunk-65WB3CQB.mjs} +9 -9
- package/{chunk-VP4HT24O.mjs → chunk-6AISIJ3O.mjs} +7 -7
- package/{chunk-LU5ODSGQ.mjs → chunk-7ULQG7YJ.mjs} +9 -9
- package/{chunk-QMODZE4A.mjs → chunk-7VU2KIBV.mjs} +7 -7
- package/chunk-BXLQYGEB.mjs +105 -0
- package/{chunk-VDFDTLU5.mjs → chunk-CGBX6OCD.mjs} +7 -7
- package/{chunk-ENDOIQ32.mjs → chunk-CJSJ3VDW.mjs} +138 -60
- package/{chunk-6ZUOXZY3.mjs → chunk-EG5RVHCZ.mjs} +9 -9
- package/{chunk-5EHEC3RT.mjs → chunk-F4RMWUXJ.mjs} +10 -10
- package/{chunk-KJTTMDZP.mjs → chunk-GBKY6QE3.mjs} +7 -7
- package/{chunk-AM7HTUI3.mjs → chunk-HF7G6PTH.mjs} +9 -9
- package/{chunk-65EE5FW3.mjs → chunk-HX5UJCA2.mjs} +7 -7
- package/{chunk-L3OISOZA.mjs → chunk-HXHJSQ2X.mjs} +9 -9
- package/{chunk-UF45URAJ.mjs → chunk-IVY6IQXZ.mjs} +9 -9
- package/{chunk-FBDTG3WD.mjs → chunk-K3QXEL6M.mjs} +20 -21
- package/{chunk-CPDLICOP.mjs → chunk-LDL7QLPB.mjs} +7 -7
- package/{chunk-ORQ52KPA.mjs → chunk-LRIO6V7H.mjs} +7 -7
- package/{chunk-MM6LQXI6.mjs → chunk-OIGZEDM3.mjs} +7 -7
- package/{chunk-PDBPFNAN.mjs → chunk-OJUTNXHL.mjs} +136 -39
- package/{chunk-KBILM3GO.mjs → chunk-OKAMQBUN.mjs} +7 -7
- package/{chunk-TDL42FZZ.mjs → chunk-PCTF5JYB.mjs} +9 -9
- package/{chunk-2BHUMNK5.mjs → chunk-PCXYLWDD.mjs} +9 -9
- package/chunk-QEPJ2RLU.mjs +18 -0
- package/{chunk-5P6NWFTX.mjs → chunk-QQCSQ3L4.mjs} +10 -10
- package/{chunk-TKHIBI4R.mjs → chunk-R5TJYTTO.mjs} +9 -9
- package/{chunk-U4ZDMJX2.mjs → chunk-T2FBV7WO.mjs} +10 -10
- package/{chunk-RWOX5QO3.mjs → chunk-TNZ33455.mjs} +7 -7
- package/{chunk-Y67MNG2X.mjs → chunk-TWOBBIQC.mjs} +9 -9
- package/{chunk-22SYVROO.mjs → chunk-TZEPVIC4.mjs} +9 -9
- package/{chunk-FIPFWGBQ.mjs → chunk-UK62IINL.mjs} +7 -7
- package/{chunk-BYAXV4TG.mjs → chunk-VTTNXB64.mjs} +7 -7
- package/{chunk-DJDG3UYR.mjs → chunk-VWKF4I2L.mjs} +9 -9
- package/financing/formalization/index.d.cts +4848 -19624
- package/financing/formalization/index.d.ts +4848 -19624
- package/financing/formalization/index.js +516 -278
- package/financing/formalization/index.mjs +33 -33
- package/financing/formalization/schemas/AlfaPFSchema.d.cts +107 -395
- package/financing/formalization/schemas/AlfaPFSchema.d.ts +107 -395
- package/financing/formalization/schemas/AlfaPFSchema.js +127 -47
- package/financing/formalization/schemas/AlfaPFSchema.mjs +3 -3
- package/financing/formalization/schemas/AlfaPJSchema.d.cts +119 -621
- package/financing/formalization/schemas/AlfaPJSchema.d.ts +119 -621
- package/financing/formalization/schemas/AlfaPJSchema.js +188 -46
- package/financing/formalization/schemas/AlfaPJSchema.mjs +2 -2
- package/financing/formalization/schemas/BancoDoBrasilPFSchema.d.cts +107 -395
- package/financing/formalization/schemas/BancoDoBrasilPFSchema.d.ts +107 -395
- package/financing/formalization/schemas/BancoDoBrasilPFSchema.js +127 -47
- package/financing/formalization/schemas/BancoDoBrasilPFSchema.mjs +3 -3
- package/financing/formalization/schemas/BancoDoBrasilPJSchema.d.cts +119 -621
- package/financing/formalization/schemas/BancoDoBrasilPJSchema.d.ts +119 -621
- package/financing/formalization/schemas/BancoDoBrasilPJSchema.js +188 -46
- package/financing/formalization/schemas/BancoDoBrasilPJSchema.mjs +2 -2
- package/financing/formalization/schemas/BtgPFSchema.d.cts +107 -395
- package/financing/formalization/schemas/BtgPFSchema.d.ts +107 -395
- package/financing/formalization/schemas/BtgPFSchema.js +127 -47
- package/financing/formalization/schemas/BtgPFSchema.mjs +3 -3
- package/financing/formalization/schemas/BtgPJSchema.d.cts +147 -747
- package/financing/formalization/schemas/BtgPJSchema.d.ts +147 -747
- package/financing/formalization/schemas/BtgPJSchema.js +193 -47
- package/financing/formalization/schemas/BtgPJSchema.mjs +3 -3
- package/financing/formalization/schemas/BvPFSchema.d.cts +125 -477
- package/financing/formalization/schemas/BvPFSchema.d.ts +125 -477
- package/financing/formalization/schemas/BvPFSchema.js +129 -49
- package/financing/formalization/schemas/BvPFSchema.mjs +3 -3
- package/financing/formalization/schemas/BvPJSchema.d.cts +149 -819
- package/financing/formalization/schemas/BvPJSchema.d.ts +149 -819
- package/financing/formalization/schemas/BvPJSchema.js +193 -47
- package/financing/formalization/schemas/BvPJSchema.mjs +3 -3
- package/financing/formalization/schemas/CaixaEconomicaFederalPFSchema.d.cts +107 -395
- package/financing/formalization/schemas/CaixaEconomicaFederalPFSchema.d.ts +107 -395
- package/financing/formalization/schemas/CaixaEconomicaFederalPFSchema.js +127 -47
- package/financing/formalization/schemas/CaixaEconomicaFederalPFSchema.mjs +3 -3
- package/financing/formalization/schemas/CaixaEconomicaFederalPJSchema.d.cts +119 -621
- package/financing/formalization/schemas/CaixaEconomicaFederalPJSchema.d.ts +119 -621
- package/financing/formalization/schemas/CaixaEconomicaFederalPJSchema.js +188 -46
- package/financing/formalization/schemas/CaixaEconomicaFederalPJSchema.mjs +2 -2
- package/financing/formalization/schemas/CashMePFSchema.d.cts +107 -395
- package/financing/formalization/schemas/CashMePFSchema.d.ts +107 -395
- package/financing/formalization/schemas/CashMePFSchema.js +127 -47
- package/financing/formalization/schemas/CashMePFSchema.mjs +3 -3
- package/financing/formalization/schemas/CashMePJSchema.d.cts +119 -621
- package/financing/formalization/schemas/CashMePJSchema.d.ts +119 -621
- package/financing/formalization/schemas/CashMePJSchema.js +188 -46
- package/financing/formalization/schemas/CashMePJSchema.mjs +2 -2
- package/financing/formalization/schemas/Credito77PFSchema.d.cts +107 -395
- package/financing/formalization/schemas/Credito77PFSchema.d.ts +107 -395
- package/financing/formalization/schemas/Credito77PFSchema.js +127 -47
- package/financing/formalization/schemas/Credito77PFSchema.mjs +3 -3
- package/financing/formalization/schemas/Credito77PJSchema.d.cts +119 -621
- package/financing/formalization/schemas/Credito77PJSchema.d.ts +119 -621
- package/financing/formalization/schemas/Credito77PJSchema.js +188 -46
- package/financing/formalization/schemas/Credito77PJSchema.mjs +2 -2
- package/financing/formalization/schemas/EosPFSchema.d.cts +107 -395
- package/financing/formalization/schemas/EosPFSchema.d.ts +107 -395
- package/financing/formalization/schemas/EosPFSchema.js +127 -47
- package/financing/formalization/schemas/EosPFSchema.mjs +3 -3
- package/financing/formalization/schemas/EosPJSchema.d.cts +119 -621
- package/financing/formalization/schemas/EosPJSchema.d.ts +119 -621
- package/financing/formalization/schemas/EosPJSchema.js +188 -46
- package/financing/formalization/schemas/EosPJSchema.mjs +2 -2
- package/financing/formalization/schemas/HdtEnergyPFSchema.d.cts +107 -395
- package/financing/formalization/schemas/HdtEnergyPFSchema.d.ts +107 -395
- package/financing/formalization/schemas/HdtEnergyPFSchema.js +127 -47
- package/financing/formalization/schemas/HdtEnergyPFSchema.mjs +3 -3
- package/financing/formalization/schemas/HdtEnergyPJSchema.d.cts +119 -621
- package/financing/formalization/schemas/HdtEnergyPJSchema.d.ts +119 -621
- package/financing/formalization/schemas/HdtEnergyPJSchema.js +188 -46
- package/financing/formalization/schemas/HdtEnergyPJSchema.mjs +2 -2
- package/financing/formalization/schemas/LosangoPFSchema.d.cts +107 -395
- package/financing/formalization/schemas/LosangoPFSchema.d.ts +107 -395
- package/financing/formalization/schemas/LosangoPFSchema.js +127 -47
- package/financing/formalization/schemas/LosangoPFSchema.mjs +3 -3
- package/financing/formalization/schemas/LosangoPJSchema.d.cts +119 -621
- package/financing/formalization/schemas/LosangoPJSchema.d.ts +119 -621
- package/financing/formalization/schemas/LosangoPJSchema.js +188 -46
- package/financing/formalization/schemas/LosangoPJSchema.mjs +2 -2
- package/financing/formalization/schemas/SafraPFSchema.d.cts +107 -395
- package/financing/formalization/schemas/SafraPFSchema.d.ts +107 -395
- package/financing/formalization/schemas/SafraPFSchema.js +127 -47
- package/financing/formalization/schemas/SafraPFSchema.mjs +3 -3
- package/financing/formalization/schemas/SafraPJSchema.d.cts +119 -621
- package/financing/formalization/schemas/SafraPJSchema.d.ts +119 -621
- package/financing/formalization/schemas/SafraPJSchema.js +188 -46
- package/financing/formalization/schemas/SafraPJSchema.mjs +2 -2
- package/financing/formalization/schemas/SantanderPFSchema.d.cts +107 -395
- package/financing/formalization/schemas/SantanderPFSchema.d.ts +107 -395
- package/financing/formalization/schemas/SantanderPFSchema.js +127 -47
- package/financing/formalization/schemas/SantanderPFSchema.mjs +3 -3
- package/financing/formalization/schemas/SantanderPJSchema.d.cts +119 -621
- package/financing/formalization/schemas/SantanderPJSchema.d.ts +119 -621
- package/financing/formalization/schemas/SantanderPJSchema.js +188 -46
- package/financing/formalization/schemas/SantanderPJSchema.mjs +2 -2
- package/financing/formalization/schemas/SolAgoraPFSchema.d.cts +107 -395
- package/financing/formalization/schemas/SolAgoraPFSchema.d.ts +107 -395
- package/financing/formalization/schemas/SolAgoraPFSchema.js +127 -47
- package/financing/formalization/schemas/SolAgoraPFSchema.mjs +3 -3
- package/financing/formalization/schemas/SolAgoraPJSchema.d.cts +145 -725
- package/financing/formalization/schemas/SolAgoraPJSchema.d.ts +145 -725
- package/financing/formalization/schemas/SolAgoraPJSchema.js +193 -47
- package/financing/formalization/schemas/SolAgoraPJSchema.mjs +3 -3
- package/financing/formalization/schemas/SolfacilPFSchema.d.cts +107 -395
- package/financing/formalization/schemas/SolfacilPFSchema.d.ts +107 -395
- package/financing/formalization/schemas/SolfacilPFSchema.js +127 -47
- package/financing/formalization/schemas/SolfacilPFSchema.mjs +3 -3
- package/financing/formalization/schemas/SolfacilPJSchema.d.cts +131 -679
- package/financing/formalization/schemas/SolfacilPJSchema.d.ts +131 -679
- package/financing/formalization/schemas/SolfacilPJSchema.js +188 -46
- package/financing/formalization/schemas/SolfacilPJSchema.mjs +2 -2
- package/financing/formalization/schemas/UnifiedPFSchema.d.cts +185 -557
- package/financing/formalization/schemas/UnifiedPFSchema.d.ts +185 -557
- package/financing/formalization/schemas/UnifiedPFSchema.js +141 -61
- package/financing/formalization/schemas/UnifiedPFSchema.mjs +3 -3
- package/financing/formalization/schemas/UnifiedPJSchema.d.cts +265 -1269
- package/financing/formalization/schemas/UnifiedPJSchema.d.ts +265 -1269
- package/financing/formalization/schemas/UnifiedPJSchema.js +238 -92
- package/financing/formalization/schemas/UnifiedPJSchema.mjs +3 -3
- package/index.d.cts +2 -1
- package/index.d.ts +2 -1
- package/index.js +516 -278
- package/index.mjs +33 -33
- package/package.json +2 -2
- package/chunk-4PZYGTUU.mjs +0 -105
- package/chunk-JZ7DY7SU.mjs +0 -13
|
@@ -2,48 +2,85 @@
|
|
|
2
2
|
|
|
3
3
|
var zod = require('zod');
|
|
4
4
|
|
|
5
|
-
// src/
|
|
5
|
+
// src/shared/fields/primitives.ts
|
|
6
6
|
var REQUIRED_MESSAGE = "Campo obrigat\xF3rio";
|
|
7
|
-
var REQUIRED_STRING_PARAMS = {
|
|
8
|
-
required_error: REQUIRED_MESSAGE,
|
|
9
|
-
invalid_type_error: REQUIRED_MESSAGE
|
|
10
|
-
};
|
|
11
7
|
function requiredString() {
|
|
12
|
-
return zod.z.string(
|
|
8
|
+
return zod.z.string({ error: REQUIRED_MESSAGE });
|
|
13
9
|
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
return
|
|
10
|
+
var DEFAULT_TEXT_MAX_LENGTH = 255;
|
|
11
|
+
function textField(maxLength = DEFAULT_TEXT_MAX_LENGTH) {
|
|
12
|
+
return requiredString().trim().min(1, REQUIRED_MESSAGE).max(maxLength, `M\xE1ximo ${maxLength} caracteres`);
|
|
17
13
|
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
14
|
+
function requiredNumber(invalidTypeMessage) {
|
|
15
|
+
return zod.z.number({
|
|
16
|
+
error: (issue) => issue.input === void 0 ? REQUIRED_MESSAGE : invalidTypeMessage
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
requiredNumber("Valor num\xE9rico inv\xE1lido").nonnegative(
|
|
20
|
+
"Valor n\xE3o pode ser negativo"
|
|
21
|
+
);
|
|
22
|
+
var integerField = requiredNumber("Valor num\xE9rico inv\xE1lido").int("Deve ser um n\xFAmero inteiro").nonnegative("Valor n\xE3o pode ser negativo");
|
|
23
|
+
function optionalField(schema) {
|
|
24
|
+
return zod.z.preprocess(
|
|
25
|
+
(value) => typeof value === "string" && value.trim() === "" ? void 0 : value,
|
|
26
|
+
schema.optional()
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
function unrecognizedKeysMessage(keys) {
|
|
30
|
+
const list = keys.map((key) => `"${key}"`).join(", ");
|
|
31
|
+
return keys.length === 1 ? `Campo n\xE3o reconhecido: ${list}` : `Campos n\xE3o reconhecidos: ${list}`;
|
|
32
|
+
}
|
|
33
|
+
function requiredObject(shape) {
|
|
34
|
+
return zod.z.object(shape, {
|
|
35
|
+
error: (issue) => {
|
|
36
|
+
if (issue.code === "invalid_type") {
|
|
37
|
+
return REQUIRED_MESSAGE;
|
|
38
|
+
}
|
|
39
|
+
if (issue.code === "unrecognized_keys") {
|
|
40
|
+
return unrecognizedKeysMessage(issue.keys);
|
|
25
41
|
}
|
|
26
|
-
return
|
|
42
|
+
return void 0;
|
|
27
43
|
}
|
|
28
44
|
});
|
|
29
45
|
}
|
|
46
|
+
function requiredArray(element) {
|
|
47
|
+
return zod.z.array(element, {
|
|
48
|
+
error: (issue) => issue.code === "invalid_type" ? REQUIRED_MESSAGE : void 0
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
function enumField(values) {
|
|
52
|
+
return zod.z.enum(values, {
|
|
53
|
+
// No zod 4 todo input fora da lista (inclusive undefined/null) gera um único
|
|
54
|
+
// issue `invalid_value`. Tratamos ausência, tipo inválido e string vazia
|
|
55
|
+
// (select não preenchido) como "obrigatório"; um valor de fato inválido cai
|
|
56
|
+
// na mensagem padrão do zod (retornar undefined delega ao error map default).
|
|
57
|
+
error: (issue) => typeof issue.input !== "string" || issue.input === "" ? REQUIRED_MESSAGE : void 0
|
|
58
|
+
});
|
|
59
|
+
}
|
|
30
60
|
var MAX_UPLOAD_BYTES = 5 * 1024 * 1024;
|
|
31
61
|
var ACCEPTED_UPLOAD_MIME = ["image/jpeg", "image/png", "application/pdf"];
|
|
32
|
-
var
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
)
|
|
62
|
+
var UPLOAD_URL_PROTOCOL = /^https$/;
|
|
63
|
+
var UPLOAD_URL_HOSTNAME = /^(?!localhost$)(?!(\d{1,3}\.){3}\d{1,3}$)[a-z0-9.-]+$/i;
|
|
64
|
+
var fileUploadField = requiredObject({
|
|
65
|
+
url: optionalField(
|
|
66
|
+
zod.z.url({
|
|
67
|
+
protocol: UPLOAD_URL_PROTOCOL,
|
|
68
|
+
hostname: UPLOAD_URL_HOSTNAME,
|
|
69
|
+
error: "URL do arquivo inv\xE1lida"
|
|
70
|
+
})
|
|
71
|
+
),
|
|
72
|
+
mime: zod.z.enum(ACCEPTED_UPLOAD_MIME, { error: "Formato deve ser JPEG, PNG ou PDF" }),
|
|
73
|
+
sizeBytes: requiredNumber("Tamanho do arquivo inv\xE1lido").int("Tamanho do arquivo deve ser um n\xFAmero inteiro").positive("Tamanho do arquivo deve ser positivo").max(MAX_UPLOAD_BYTES, "Arquivo deve ter no m\xE1ximo 5MB")
|
|
74
|
+
});
|
|
42
75
|
|
|
43
76
|
// src/shared/enums/document-type.ts
|
|
44
77
|
var DocumentTypeEnum = enumField([
|
|
45
78
|
"documento_de_identidade",
|
|
46
|
-
"carteira_nacional_de_habilita\xE7\xE3o"
|
|
79
|
+
"carteira_nacional_de_habilita\xE7\xE3o",
|
|
80
|
+
// Exigido pela RN-015 para nacionalidade estrangeira. Sem este membro a
|
|
81
|
+
// regra seria insatisfazível: todo schema é .strict() com type_doc
|
|
82
|
+
// restrito a este enum.
|
|
83
|
+
"registro_de_estrangeiro"
|
|
47
84
|
]);
|
|
48
85
|
|
|
49
86
|
// src/shared/enums/nationality.ts
|
|
@@ -117,7 +154,10 @@ var PATTERNS = {
|
|
|
117
154
|
cep: /^\d{8}$/,
|
|
118
155
|
phoneBR: /^\d{11}$/,
|
|
119
156
|
email: /^[^\s@]+@[^\s@]+\.[^\s@]+$/,
|
|
120
|
-
dateDMY: /^\d{2}\/\d{2}\/\d{4}
|
|
157
|
+
dateDMY: /^\d{2}\/\d{2}\/\d{4}$/,
|
|
158
|
+
// Formato do RNE, exigido pela RN-015 para nacionalidade estrangeira.
|
|
159
|
+
rneNumber: /^[A-Za-z0-9]+$/
|
|
160
|
+
};
|
|
121
161
|
|
|
122
162
|
// src/shared/regex/validators.ts
|
|
123
163
|
function onlyDigits(value) {
|
|
@@ -197,6 +237,13 @@ function isNotFutureDMY(value, reference = /* @__PURE__ */ new Date()) {
|
|
|
197
237
|
}
|
|
198
238
|
return date.getTime() <= reference.getTime();
|
|
199
239
|
}
|
|
240
|
+
function yearsSinceDMY(value, reference = /* @__PURE__ */ new Date()) {
|
|
241
|
+
const date = parseDMY(value);
|
|
242
|
+
if (!date) {
|
|
243
|
+
return null;
|
|
244
|
+
}
|
|
245
|
+
return ageInYears(date, reference);
|
|
246
|
+
}
|
|
200
247
|
|
|
201
248
|
// src/shared/regex/index.ts
|
|
202
249
|
function requiredFormatString() {
|
|
@@ -227,27 +274,63 @@ function parseBRLCurrency(value) {
|
|
|
227
274
|
if (typeof value !== "string") {
|
|
228
275
|
return value;
|
|
229
276
|
}
|
|
230
|
-
const
|
|
231
|
-
if (
|
|
277
|
+
const normalized = value.replace(/R\$/gi, "").replace(/\s/g, "").replace(/\./g, "").replace(",", ".");
|
|
278
|
+
if (normalized === "") {
|
|
232
279
|
return void 0;
|
|
233
280
|
}
|
|
234
|
-
const normalized = trimmed.replace(/R\$/gi, "").replace(/\s/g, "").replace(/\./g, "").replace(",", ".");
|
|
235
281
|
const parsed = Number(normalized);
|
|
236
282
|
return Number.isNaN(parsed) ? value : parsed;
|
|
237
283
|
}
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
);
|
|
242
|
-
zod.z.
|
|
284
|
+
function brlAmount() {
|
|
285
|
+
return requiredNumber("Valor monet\xE1rio inv\xE1lido").positive("Valor deve ser positivo");
|
|
286
|
+
}
|
|
287
|
+
zod.z.preprocess(parseBRLCurrency, brlAmount());
|
|
288
|
+
var optionalCurrencySchema = zod.z.preprocess(parseBRLCurrency, brlAmount().optional());
|
|
289
|
+
requiredNumber("Valor num\xE9rico inv\xE1lido").int("Deve ser um n\xFAmero inteiro").min(1, "M\xEDnimo 1").max(28, "M\xE1ximo 28");
|
|
243
290
|
var formalizationExtras = {
|
|
244
291
|
voucher_local_installation_address: fileUploadField,
|
|
245
|
-
proof_kinship_type: ProofKinshipTypeEnum
|
|
292
|
+
proof_kinship_type: optionalField(ProofKinshipTypeEnum),
|
|
246
293
|
proof_kinship: fileUploadField.optional(),
|
|
247
294
|
document_front_upload: fileUploadField,
|
|
248
295
|
document_back_upload: fileUploadField,
|
|
249
296
|
rd_re_insurance_toggle: zod.z.boolean().default(true)
|
|
250
297
|
};
|
|
298
|
+
|
|
299
|
+
// src/domains/financing/enums/civil-status.ts
|
|
300
|
+
var CIVIL_STATUS_REQUIRING_PARTNER = ["casado"];
|
|
301
|
+
var PARTNER_FIELDS = [
|
|
302
|
+
"partner_name",
|
|
303
|
+
"partner_birth",
|
|
304
|
+
"partner_type_doc",
|
|
305
|
+
"partner_doc",
|
|
306
|
+
"partner_cpf",
|
|
307
|
+
"partner_city",
|
|
308
|
+
"communion_regime"
|
|
309
|
+
];
|
|
310
|
+
|
|
311
|
+
// src/domains/financing/enums/occupation.ts
|
|
312
|
+
var OCCUPATIONS_REQUIRING_CNPJ = ["empresario", "empresario_ou_proprietario"];
|
|
313
|
+
|
|
314
|
+
// src/domains/financing/formalization/refinements.ts
|
|
315
|
+
var RG_MAX_EMISSION_YEARS = 10;
|
|
316
|
+
function applyPartnerRefinement(data, ctx) {
|
|
317
|
+
const civilStatus = data.civil_status;
|
|
318
|
+
const requiresPartner = typeof civilStatus === "string" && CIVIL_STATUS_REQUIRING_PARTNER.includes(civilStatus);
|
|
319
|
+
if (!requiresPartner) {
|
|
320
|
+
return;
|
|
321
|
+
}
|
|
322
|
+
for (const field of PARTNER_FIELDS) {
|
|
323
|
+
const value = data[field];
|
|
324
|
+
const isEmpty = value === void 0 || value === null || typeof value === "string" && value.trim().length === 0;
|
|
325
|
+
if (isEmpty) {
|
|
326
|
+
ctx.addIssue({
|
|
327
|
+
code: "custom",
|
|
328
|
+
path: [field],
|
|
329
|
+
message: "Campo obrigat\xF3rio para o estado civil informado"
|
|
330
|
+
});
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
}
|
|
251
334
|
function applyCommonRefinements(data, ctx) {
|
|
252
335
|
const accountInThirdPartyName = data.energy_account_in_requester_name === "sim";
|
|
253
336
|
if (!accountInThirdPartyName) {
|
|
@@ -255,56 +338,119 @@ function applyCommonRefinements(data, ctx) {
|
|
|
255
338
|
}
|
|
256
339
|
if (!data.proof_kinship_type) {
|
|
257
340
|
ctx.addIssue({
|
|
258
|
-
code:
|
|
341
|
+
code: "custom",
|
|
259
342
|
path: ["proof_kinship_type"],
|
|
260
343
|
message: "Tipo de comprovante \xE9 obrigat\xF3rio quando a conta est\xE1 em nome de terceiro"
|
|
261
344
|
});
|
|
262
345
|
}
|
|
263
346
|
if (!data.proof_kinship) {
|
|
264
347
|
ctx.addIssue({
|
|
265
|
-
code:
|
|
348
|
+
code: "custom",
|
|
266
349
|
path: ["proof_kinship"],
|
|
267
350
|
message: "Documento de v\xEDnculo \xE9 obrigat\xF3rio quando a conta est\xE1 em nome de terceiro"
|
|
268
351
|
});
|
|
269
352
|
}
|
|
270
353
|
}
|
|
354
|
+
var FOREIGN_DOCUMENT_TYPE = "registro_de_estrangeiro";
|
|
355
|
+
function applyForeignDocumentRefinement(data, ctx) {
|
|
356
|
+
const nationality = data.nationality;
|
|
357
|
+
const isForeign = typeof nationality === "string" && nationality.toLowerCase() !== NATIONALITY_BRAZIL;
|
|
358
|
+
if (!isForeign || !("type_doc" in data)) {
|
|
359
|
+
return;
|
|
360
|
+
}
|
|
361
|
+
if (data.type_doc !== FOREIGN_DOCUMENT_TYPE) {
|
|
362
|
+
ctx.addIssue({
|
|
363
|
+
code: "custom",
|
|
364
|
+
path: ["type_doc"],
|
|
365
|
+
message: "Para nacionalidade estrangeira, o documento deve ser Registro de Estrangeiro (RNE)"
|
|
366
|
+
});
|
|
367
|
+
return;
|
|
368
|
+
}
|
|
369
|
+
if (typeof data.doc === "string" && !PATTERNS.rneNumber.test(data.doc)) {
|
|
370
|
+
ctx.addIssue({
|
|
371
|
+
code: "custom",
|
|
372
|
+
path: ["doc"],
|
|
373
|
+
message: "RNE deve conter apenas letras e n\xFAmeros"
|
|
374
|
+
});
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
function isRecord(data) {
|
|
378
|
+
return typeof data === "object" && data !== null;
|
|
379
|
+
}
|
|
380
|
+
function applyPfRefinements(data, ctx) {
|
|
381
|
+
if (!isRecord(data)) {
|
|
382
|
+
return;
|
|
383
|
+
}
|
|
384
|
+
applyCommonRefinements(data, ctx);
|
|
385
|
+
applyPartnerRefinement(data, ctx);
|
|
386
|
+
if ("nature_of_occupation" in data && typeof data.nature_of_occupation === "string" && OCCUPATIONS_REQUIRING_CNPJ.includes(data.nature_of_occupation) && !data.cnpj_proprietary) {
|
|
387
|
+
ctx.addIssue({
|
|
388
|
+
code: "custom",
|
|
389
|
+
path: ["cnpj_proprietary"],
|
|
390
|
+
message: "CNPJ do propriet\xE1rio \xE9 obrigat\xF3rio para esta ocupa\xE7\xE3o"
|
|
391
|
+
});
|
|
392
|
+
}
|
|
393
|
+
if (data.type_doc === "documento_de_identidade" && typeof data.doc_issue_date === "string") {
|
|
394
|
+
const years = yearsSinceDMY(data.doc_issue_date);
|
|
395
|
+
if (years !== null && years > RG_MAX_EMISSION_YEARS) {
|
|
396
|
+
ctx.addIssue({
|
|
397
|
+
code: "custom",
|
|
398
|
+
path: ["doc_issue_date"],
|
|
399
|
+
message: `RG deve ter no m\xE1ximo ${RG_MAX_EMISSION_YEARS} anos de emiss\xE3o`
|
|
400
|
+
});
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
applyForeignDocumentRefinement(data, ctx);
|
|
404
|
+
}
|
|
271
405
|
function applyPjRefinements(data, ctx) {
|
|
406
|
+
if (!isRecord(data)) {
|
|
407
|
+
return;
|
|
408
|
+
}
|
|
272
409
|
applyCommonRefinements(data, ctx);
|
|
273
410
|
}
|
|
411
|
+
function onlyUnknownKeysAborted(payload) {
|
|
412
|
+
return payload.aborted !== true && !payload.issues.some((issue) => issue.continue !== true && issue.code !== "unrecognized_keys");
|
|
413
|
+
}
|
|
414
|
+
zod.z.superRefine(applyPfRefinements, {
|
|
415
|
+
when: onlyUnknownKeysAborted
|
|
416
|
+
});
|
|
417
|
+
var pjRefinement = zod.z.superRefine(applyPjRefinements, {
|
|
418
|
+
when: onlyUnknownKeysAborted
|
|
419
|
+
});
|
|
274
420
|
|
|
275
421
|
// src/domains/financing/formalization/schemas/UnifiedPJSchema.ts
|
|
276
|
-
var unifiedPjObject =
|
|
422
|
+
var unifiedPjObject = requiredObject({
|
|
277
423
|
...formalizationExtras,
|
|
278
|
-
financing_company:
|
|
424
|
+
financing_company: requiredObject({
|
|
279
425
|
corporate_name: textField(),
|
|
280
426
|
cnpj: cnpjSchema,
|
|
281
427
|
foundation_date: issueDateSchema,
|
|
282
428
|
address: textField(),
|
|
283
429
|
number: textField(),
|
|
284
430
|
email: emailSchema,
|
|
285
|
-
complement: textField(15)
|
|
431
|
+
complement: optionalField(textField(15)),
|
|
286
432
|
phone: phoneBRSchema,
|
|
287
433
|
district: textField(),
|
|
288
434
|
legal_nature: textField(),
|
|
289
435
|
city: textField(),
|
|
290
436
|
state: UfEnum,
|
|
291
437
|
cep: cepSchema,
|
|
292
|
-
economic_activity: textField()
|
|
293
|
-
economic_activity_group: textField()
|
|
294
|
-
monthly_income:
|
|
295
|
-
residence_situation: textField()
|
|
296
|
-
months_in_residence: integerField
|
|
297
|
-
capital_social:
|
|
438
|
+
economic_activity: optionalField(textField()),
|
|
439
|
+
economic_activity_group: optionalField(textField()),
|
|
440
|
+
monthly_income: optionalCurrencySchema,
|
|
441
|
+
residence_situation: optionalField(textField()),
|
|
442
|
+
months_in_residence: optionalField(integerField),
|
|
443
|
+
capital_social: optionalCurrencySchema
|
|
298
444
|
}).strict(),
|
|
299
|
-
financing_company_guarantor:
|
|
300
|
-
|
|
445
|
+
financing_company_guarantor: requiredArray(
|
|
446
|
+
requiredObject({
|
|
301
447
|
name: textField(),
|
|
302
448
|
cpf: cpfSchema,
|
|
303
449
|
birth_date: birthDateSchema,
|
|
304
450
|
address: textField(),
|
|
305
451
|
number: textField(),
|
|
306
452
|
cep: cepSchema,
|
|
307
|
-
complement: textField(15)
|
|
453
|
+
complement: optionalField(textField(15)),
|
|
308
454
|
cellphone: phoneBRSchema,
|
|
309
455
|
email: emailSchema,
|
|
310
456
|
district: textField(),
|
|
@@ -313,35 +459,35 @@ var unifiedPjObject = zod.z.object({
|
|
|
313
459
|
state: UfEnum,
|
|
314
460
|
mother_name: textField(),
|
|
315
461
|
nationality: NationalityEnum.default(NATIONALITY_BRAZIL),
|
|
316
|
-
office: textField()
|
|
317
|
-
phone: phoneBRSchema
|
|
318
|
-
civil_status: textField()
|
|
319
|
-
residence_situation: textField()
|
|
320
|
-
months_in_residence: integerField
|
|
321
|
-
type_doc: DocumentTypeEnum
|
|
322
|
-
doc: textField()
|
|
323
|
-
issuing_body: textField()
|
|
324
|
-
uf_issuing_body: UfEnum
|
|
325
|
-
doc_issue_date: issueDateSchema
|
|
326
|
-
doc_expiration_date: dateDMYSchema
|
|
327
|
-
monthly_income:
|
|
328
|
-
patrimony:
|
|
329
|
-
naturalness: textField()
|
|
330
|
-
uf_naturalness: UfEnum
|
|
331
|
-
pep_relationship: textField()
|
|
332
|
-
entry_date: issueDateSchema
|
|
333
|
-
doc_issuance_uf: UfEnum
|
|
462
|
+
office: optionalField(textField()),
|
|
463
|
+
phone: optionalField(phoneBRSchema),
|
|
464
|
+
civil_status: optionalField(textField()),
|
|
465
|
+
residence_situation: optionalField(textField()),
|
|
466
|
+
months_in_residence: optionalField(integerField),
|
|
467
|
+
type_doc: optionalField(DocumentTypeEnum),
|
|
468
|
+
doc: optionalField(textField()),
|
|
469
|
+
issuing_body: optionalField(textField()),
|
|
470
|
+
uf_issuing_body: optionalField(UfEnum),
|
|
471
|
+
doc_issue_date: optionalField(issueDateSchema),
|
|
472
|
+
doc_expiration_date: optionalField(dateDMYSchema),
|
|
473
|
+
monthly_income: optionalCurrencySchema,
|
|
474
|
+
patrimony: optionalCurrencySchema,
|
|
475
|
+
naturalness: optionalField(textField()),
|
|
476
|
+
uf_naturalness: optionalField(UfEnum),
|
|
477
|
+
pep_relationship: optionalField(textField()),
|
|
478
|
+
entry_date: optionalField(issueDateSchema),
|
|
479
|
+
doc_issuance_uf: optionalField(UfEnum)
|
|
334
480
|
}).strict()
|
|
335
481
|
).optional(),
|
|
336
|
-
financing_company_qsa:
|
|
337
|
-
|
|
482
|
+
financing_company_qsa: requiredArray(
|
|
483
|
+
requiredObject({
|
|
338
484
|
name: textField(),
|
|
339
485
|
cpf: cpfSchema,
|
|
340
486
|
birth_date: birthDateSchema,
|
|
341
487
|
address: textField(),
|
|
342
488
|
number: textField(),
|
|
343
489
|
cep: cepSchema,
|
|
344
|
-
complement: textField(15)
|
|
490
|
+
complement: optionalField(textField(15)),
|
|
345
491
|
cellphone: phoneBRSchema,
|
|
346
492
|
email: emailSchema,
|
|
347
493
|
district: textField(),
|
|
@@ -350,28 +496,28 @@ var unifiedPjObject = zod.z.object({
|
|
|
350
496
|
state: UfEnum,
|
|
351
497
|
mother_name: textField(),
|
|
352
498
|
nationality: NationalityEnum.default(NATIONALITY_BRAZIL),
|
|
353
|
-
office: textField()
|
|
354
|
-
phone: phoneBRSchema
|
|
355
|
-
civil_status: textField()
|
|
356
|
-
residence_situation: textField()
|
|
357
|
-
months_in_residence: integerField
|
|
358
|
-
type_doc: DocumentTypeEnum
|
|
359
|
-
doc: textField()
|
|
360
|
-
issuing_body: textField()
|
|
361
|
-
uf_issuing_body: UfEnum
|
|
362
|
-
doc_issue_date: issueDateSchema
|
|
363
|
-
doc_expiration_date: dateDMYSchema
|
|
364
|
-
monthly_income:
|
|
365
|
-
patrimony:
|
|
366
|
-
naturalness: textField()
|
|
367
|
-
uf_naturalness: UfEnum
|
|
368
|
-
pep_relationship: textField()
|
|
369
|
-
entry_date: issueDateSchema
|
|
370
|
-
doc_issuance_uf: UfEnum
|
|
499
|
+
office: optionalField(textField()),
|
|
500
|
+
phone: optionalField(phoneBRSchema),
|
|
501
|
+
civil_status: optionalField(textField()),
|
|
502
|
+
residence_situation: optionalField(textField()),
|
|
503
|
+
months_in_residence: optionalField(integerField),
|
|
504
|
+
type_doc: optionalField(DocumentTypeEnum),
|
|
505
|
+
doc: optionalField(textField()),
|
|
506
|
+
issuing_body: optionalField(textField()),
|
|
507
|
+
uf_issuing_body: optionalField(UfEnum),
|
|
508
|
+
doc_issue_date: optionalField(issueDateSchema),
|
|
509
|
+
doc_expiration_date: optionalField(dateDMYSchema),
|
|
510
|
+
monthly_income: optionalCurrencySchema,
|
|
511
|
+
patrimony: optionalCurrencySchema,
|
|
512
|
+
naturalness: optionalField(textField()),
|
|
513
|
+
uf_naturalness: optionalField(UfEnum),
|
|
514
|
+
pep_relationship: optionalField(textField()),
|
|
515
|
+
entry_date: optionalField(issueDateSchema),
|
|
516
|
+
doc_issuance_uf: optionalField(UfEnum)
|
|
371
517
|
}).strict()
|
|
372
518
|
).optional()
|
|
373
519
|
});
|
|
374
|
-
var unifiedPjSchema = unifiedPjObject.strict().
|
|
520
|
+
var unifiedPjSchema = unifiedPjObject.strict().check(pjRefinement);
|
|
375
521
|
|
|
376
522
|
exports.unifiedPjObject = unifiedPjObject;
|
|
377
523
|
exports.unifiedPjSchema = unifiedPjSchema;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { unifiedPjObject, unifiedPjSchema } from '../../../chunk-
|
|
2
|
-
import '../../../chunk-
|
|
3
|
-
import '../../../chunk-
|
|
1
|
+
export { unifiedPjObject, unifiedPjSchema } from '../../../chunk-BXLQYGEB.mjs';
|
|
2
|
+
import '../../../chunk-QEPJ2RLU.mjs';
|
|
3
|
+
import '../../../chunk-CJSJ3VDW.mjs';
|
package/index.d.cts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
export { BANK_SLUGS, Bank, BankEnum, BankSlug, CIVIL_STATUS_REQUIRING_PARTNER, FORMALIZATION_FIELD_META, FORMALIZATION_OPTION_LABELS, FormalizationFieldKind, FormalizationFieldMeta, FormalizationOptionField, NATIONALITY_BRAZIL, Nationality, NationalityEnum, NationalityLabels, OCCUPATIONS_REQUIRING_CNPJ, PARTNER_FIELDS, PartnerField, PersonType, UNIFIED_SLUG, UnifiedSlug,
|
|
1
|
+
export { BANK_SLUGS, Bank, BankEnum, BankSlug, CIVIL_STATUS_REQUIRING_PARTNER, FORMALIZATION_FIELD_META, FORMALIZATION_OPTION_LABELS, FormalizationFieldKind, FormalizationFieldMeta, FormalizationOptionField, NATIONALITY_BRAZIL, Nationality, NationalityEnum, NationalityLabels, OCCUPATIONS_REQUIRING_CNPJ, PARTNER_FIELDS, PartnerField, PersonType, UNIFIED_SLUG, UnifiedSlug, getFieldOptions, getFormalizationBaseSchema, getFormalizationSchema, pfBaseSchemaRegistry, pfRefinement, pfSchemaRegistry, pjBaseSchemaRegistry, pjRefinement, pjSchemaRegistry } from './financing/formalization/index.cjs';
|
|
2
2
|
export { unifiedPfObject, unifiedPfSchema } from './financing/formalization/schemas/UnifiedPFSchema.cjs';
|
|
3
3
|
export { unifiedPjObject, unifiedPjSchema } from './financing/formalization/schemas/UnifiedPJSchema.cjs';
|
|
4
4
|
import 'zod';
|
|
5
|
+
import 'zod/v4/core';
|
package/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
export { BANK_SLUGS, Bank, BankEnum, BankSlug, CIVIL_STATUS_REQUIRING_PARTNER, FORMALIZATION_FIELD_META, FORMALIZATION_OPTION_LABELS, FormalizationFieldKind, FormalizationFieldMeta, FormalizationOptionField, NATIONALITY_BRAZIL, Nationality, NationalityEnum, NationalityLabels, OCCUPATIONS_REQUIRING_CNPJ, PARTNER_FIELDS, PartnerField, PersonType, UNIFIED_SLUG, UnifiedSlug,
|
|
1
|
+
export { BANK_SLUGS, Bank, BankEnum, BankSlug, CIVIL_STATUS_REQUIRING_PARTNER, FORMALIZATION_FIELD_META, FORMALIZATION_OPTION_LABELS, FormalizationFieldKind, FormalizationFieldMeta, FormalizationOptionField, NATIONALITY_BRAZIL, Nationality, NationalityEnum, NationalityLabels, OCCUPATIONS_REQUIRING_CNPJ, PARTNER_FIELDS, PartnerField, PersonType, UNIFIED_SLUG, UnifiedSlug, getFieldOptions, getFormalizationBaseSchema, getFormalizationSchema, pfBaseSchemaRegistry, pfRefinement, pfSchemaRegistry, pjBaseSchemaRegistry, pjRefinement, pjSchemaRegistry } from './financing/formalization/index.js';
|
|
2
2
|
export { unifiedPfObject, unifiedPfSchema } from './financing/formalization/schemas/UnifiedPFSchema.js';
|
|
3
3
|
export { unifiedPjObject, unifiedPjSchema } from './financing/formalization/schemas/UnifiedPJSchema.js';
|
|
4
4
|
import 'zod';
|
|
5
|
+
import 'zod/v4/core';
|