1 | "use strict";
|
2 |
|
3 |
|
4 |
|
5 |
|
6 | Object.defineProperty(exports, "__esModule", { value: true });
|
7 | exports.openapiFormats = exports.binaryFormat = exports.byteFormat = exports.doubleFormat = exports.floatFormat = exports.int64Format = exports.int32Format = void 0;
|
8 |
|
9 |
|
10 |
|
11 | exports.int32Format = {
|
12 | name: 'int32',
|
13 | type: 'number',
|
14 | validate: (value) => {
|
15 | return (Number.isInteger(value) && value >= -2147483648 && value <= 2147483647);
|
16 | },
|
17 | async: false,
|
18 | };
|
19 |
|
20 |
|
21 |
|
22 | exports.int64Format = {
|
23 | name: 'int64',
|
24 | type: 'number',
|
25 | validate: (value) => {
|
26 | const max = Number.MAX_SAFE_INTEGER;
|
27 | const min = Number.MIN_SAFE_INTEGER;
|
28 | return Number.isInteger(value) && value >= min && value <= max;
|
29 | },
|
30 | async: false,
|
31 | };
|
32 |
|
33 |
|
34 |
|
35 | exports.floatFormat = {
|
36 | name: 'float',
|
37 | type: 'number',
|
38 | validate: (value) => {
|
39 | return value >= -Math.pow(2, 128) && value <= Math.pow(2, 128);
|
40 | },
|
41 | async: false,
|
42 | };
|
43 |
|
44 |
|
45 |
|
46 | exports.doubleFormat = {
|
47 | name: 'double',
|
48 | type: 'number',
|
49 | validate: (value) => {
|
50 | const max = Number.MAX_VALUE;
|
51 | const min = -Number.MAX_VALUE;
|
52 | return value >= min && value <= max;
|
53 | },
|
54 | async: false,
|
55 | };
|
56 |
|
57 |
|
58 |
|
59 | exports.byteFormat = {
|
60 | name: 'byte',
|
61 | type: 'string',
|
62 | validate: (value) => {
|
63 | const base64 = Buffer.from(value, 'base64').toString('base64');
|
64 | return value === base64;
|
65 | },
|
66 | async: false,
|
67 | };
|
68 |
|
69 |
|
70 |
|
71 | exports.binaryFormat = {
|
72 | name: 'binary',
|
73 | type: 'string',
|
74 | validate: (value) => true,
|
75 | async: false,
|
76 | };
|
77 | exports.openapiFormats = [
|
78 | exports.int32Format,
|
79 | exports.int64Format,
|
80 | exports.floatFormat,
|
81 | exports.doubleFormat,
|
82 | exports.byteFormat,
|
83 | exports.binaryFormat,
|
84 | ];
|
85 |
|
\ | No newline at end of file |