@palmares/schemas 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.
Files changed (219) hide show
  1. package/.turbo/turbo-build$colon$watch.log +424 -0
  2. package/.turbo/turbo-build.log +13 -0
  3. package/.turbo/turbo-build:watch.log +26 -0
  4. package/CHANGELOG.md +11 -0
  5. package/LICENSE +21 -0
  6. package/dist/cjs/src/adapter/fields/array.js +157 -0
  7. package/dist/cjs/src/adapter/fields/boolean.js +167 -0
  8. package/dist/cjs/src/adapter/fields/datetime.js +167 -0
  9. package/dist/cjs/src/adapter/fields/index.js +311 -0
  10. package/dist/cjs/src/adapter/fields/number.js +167 -0
  11. package/dist/cjs/src/adapter/fields/object.js +167 -0
  12. package/dist/cjs/src/adapter/fields/string.js +167 -0
  13. package/dist/cjs/src/adapter/fields/union.js +167 -0
  14. package/dist/cjs/src/adapter/index.js +198 -0
  15. package/dist/cjs/src/adapter/types.js +4 -0
  16. package/dist/cjs/src/compile.js +262 -0
  17. package/dist/cjs/src/conf.js +27 -0
  18. package/dist/cjs/src/constants.js +42 -0
  19. package/dist/cjs/src/domain.js +12 -0
  20. package/dist/cjs/src/exceptions.js +168 -0
  21. package/dist/cjs/src/index.js +365 -0
  22. package/dist/cjs/src/model.js +628 -0
  23. package/dist/cjs/src/parsers/convert-from-number.js +20 -0
  24. package/dist/cjs/src/parsers/convert-from-string.js +24 -0
  25. package/dist/cjs/src/parsers/index.js +25 -0
  26. package/dist/cjs/src/schema/array.js +890 -0
  27. package/dist/cjs/src/schema/boolean.js +826 -0
  28. package/dist/cjs/src/schema/datetime.js +778 -0
  29. package/dist/cjs/src/schema/index.js +17 -0
  30. package/dist/cjs/src/schema/number.js +960 -0
  31. package/dist/cjs/src/schema/object.js +999 -0
  32. package/dist/cjs/src/schema/schema.js +1788 -0
  33. package/dist/cjs/src/schema/string.js +948 -0
  34. package/dist/cjs/src/schema/types.js +4 -0
  35. package/dist/cjs/src/schema/union.js +952 -0
  36. package/dist/cjs/src/types.js +4 -0
  37. package/dist/cjs/src/utils.js +627 -0
  38. package/dist/cjs/src/validators/array.js +457 -0
  39. package/dist/cjs/src/validators/boolean.js +199 -0
  40. package/dist/cjs/src/validators/datetime.js +287 -0
  41. package/dist/cjs/src/validators/number.js +403 -0
  42. package/dist/cjs/src/validators/object.js +290 -0
  43. package/dist/cjs/src/validators/schema.js +318 -0
  44. package/dist/cjs/src/validators/string.js +439 -0
  45. package/dist/cjs/src/validators/types.js +4 -0
  46. package/dist/cjs/src/validators/union.js +232 -0
  47. package/dist/cjs/src/validators/utils.js +426 -0
  48. package/dist/cjs/tsconfig.types.tsbuildinfo +1 -0
  49. package/dist/cjs/types/adapter/fields/array.d.ts +20 -0
  50. package/dist/cjs/types/adapter/fields/array.d.ts.map +1 -0
  51. package/dist/cjs/types/adapter/fields/boolean.d.ts +25 -0
  52. package/dist/cjs/types/adapter/fields/boolean.d.ts.map +1 -0
  53. package/dist/cjs/types/adapter/fields/datetime.d.ts +25 -0
  54. package/dist/cjs/types/adapter/fields/datetime.d.ts.map +1 -0
  55. package/dist/cjs/types/adapter/fields/index.d.ts +31 -0
  56. package/dist/cjs/types/adapter/fields/index.d.ts.map +1 -0
  57. package/dist/cjs/types/adapter/fields/number.d.ts +25 -0
  58. package/dist/cjs/types/adapter/fields/number.d.ts.map +1 -0
  59. package/dist/cjs/types/adapter/fields/object.d.ts +25 -0
  60. package/dist/cjs/types/adapter/fields/object.d.ts.map +1 -0
  61. package/dist/cjs/types/adapter/fields/string.d.ts +25 -0
  62. package/dist/cjs/types/adapter/fields/string.d.ts.map +1 -0
  63. package/dist/cjs/types/adapter/fields/union.d.ts +25 -0
  64. package/dist/cjs/types/adapter/fields/union.d.ts.map +1 -0
  65. package/dist/cjs/types/adapter/index.d.ts +25 -0
  66. package/dist/cjs/types/adapter/index.d.ts.map +1 -0
  67. package/dist/cjs/types/adapter/types.d.ts +144 -0
  68. package/dist/cjs/types/adapter/types.d.ts.map +1 -0
  69. package/dist/cjs/types/compile.d.ts +3 -0
  70. package/dist/cjs/types/compile.d.ts.map +1 -0
  71. package/dist/cjs/types/conf.d.ts +16 -0
  72. package/dist/cjs/types/conf.d.ts.map +1 -0
  73. package/dist/cjs/types/constants.d.ts +6 -0
  74. package/dist/cjs/types/constants.d.ts.map +1 -0
  75. package/dist/cjs/types/domain.d.ts +21 -0
  76. package/dist/cjs/types/domain.d.ts.map +1 -0
  77. package/dist/cjs/types/exceptions.d.ts +13 -0
  78. package/dist/cjs/types/exceptions.d.ts.map +1 -0
  79. package/dist/cjs/types/index.d.ts +240 -0
  80. package/dist/cjs/types/index.d.ts.map +1 -0
  81. package/dist/cjs/types/model.d.ts +136 -0
  82. package/dist/cjs/types/model.d.ts.map +1 -0
  83. package/dist/cjs/types/parsers/convert-from-number.d.ts +15 -0
  84. package/dist/cjs/types/parsers/convert-from-number.d.ts.map +1 -0
  85. package/dist/cjs/types/parsers/convert-from-string.d.ts +9 -0
  86. package/dist/cjs/types/parsers/convert-from-string.d.ts.map +1 -0
  87. package/dist/cjs/types/parsers/index.d.ts +3 -0
  88. package/dist/cjs/types/parsers/index.d.ts.map +1 -0
  89. package/dist/cjs/types/schema/array.d.ts +429 -0
  90. package/dist/cjs/types/schema/array.d.ts.map +1 -0
  91. package/dist/cjs/types/schema/boolean.d.ts +501 -0
  92. package/dist/cjs/types/schema/boolean.d.ts.map +1 -0
  93. package/dist/cjs/types/schema/datetime.d.ts +474 -0
  94. package/dist/cjs/types/schema/datetime.d.ts.map +1 -0
  95. package/dist/cjs/types/schema/index.d.ts +4 -0
  96. package/dist/cjs/types/schema/index.d.ts.map +1 -0
  97. package/dist/cjs/types/schema/number.d.ts +667 -0
  98. package/dist/cjs/types/schema/number.d.ts.map +1 -0
  99. package/dist/cjs/types/schema/object.d.ts +450 -0
  100. package/dist/cjs/types/schema/object.d.ts.map +1 -0
  101. package/dist/cjs/types/schema/schema.d.ts +646 -0
  102. package/dist/cjs/types/schema/schema.d.ts.map +1 -0
  103. package/dist/cjs/types/schema/string.d.ts +606 -0
  104. package/dist/cjs/types/schema/string.d.ts.map +1 -0
  105. package/dist/cjs/types/schema/types.d.ts +70 -0
  106. package/dist/cjs/types/schema/types.d.ts.map +1 -0
  107. package/dist/cjs/types/schema/union.d.ts +388 -0
  108. package/dist/cjs/types/schema/union.d.ts.map +1 -0
  109. package/dist/cjs/types/types.d.ts +11 -0
  110. package/dist/cjs/types/types.d.ts.map +1 -0
  111. package/dist/cjs/types/utils.d.ts +79 -0
  112. package/dist/cjs/types/utils.d.ts.map +1 -0
  113. package/dist/cjs/types/validators/array.d.ts +8 -0
  114. package/dist/cjs/types/validators/array.d.ts.map +1 -0
  115. package/dist/cjs/types/validators/boolean.d.ts +4 -0
  116. package/dist/cjs/types/validators/boolean.d.ts.map +1 -0
  117. package/dist/cjs/types/validators/datetime.d.ts +7 -0
  118. package/dist/cjs/types/validators/datetime.d.ts.map +1 -0
  119. package/dist/cjs/types/validators/number.d.ts +10 -0
  120. package/dist/cjs/types/validators/number.d.ts.map +1 -0
  121. package/dist/cjs/types/validators/object.d.ts +6 -0
  122. package/dist/cjs/types/validators/object.d.ts.map +1 -0
  123. package/dist/cjs/types/validators/schema.d.ts +10 -0
  124. package/dist/cjs/types/validators/schema.d.ts.map +1 -0
  125. package/dist/cjs/types/validators/string.d.ts +12 -0
  126. package/dist/cjs/types/validators/string.d.ts.map +1 -0
  127. package/dist/cjs/types/validators/types.d.ts +2 -0
  128. package/dist/cjs/types/validators/types.d.ts.map +1 -0
  129. package/dist/cjs/types/validators/union.d.ts +4 -0
  130. package/dist/cjs/types/validators/union.d.ts.map +1 -0
  131. package/dist/cjs/types/validators/utils.d.ts +83 -0
  132. package/dist/cjs/types/validators/utils.d.ts.map +1 -0
  133. package/dist/esm/src/adapter/fields/array.js +13 -0
  134. package/dist/esm/src/adapter/fields/boolean.js +20 -0
  135. package/dist/esm/src/adapter/fields/datetime.js +20 -0
  136. package/dist/esm/src/adapter/fields/index.js +37 -0
  137. package/dist/esm/src/adapter/fields/number.js +20 -0
  138. package/dist/esm/src/adapter/fields/object.js +20 -0
  139. package/dist/esm/src/adapter/fields/string.js +20 -0
  140. package/dist/esm/src/adapter/fields/union.js +20 -0
  141. package/dist/esm/src/adapter/index.js +18 -0
  142. package/dist/esm/src/adapter/types.js +1 -0
  143. package/dist/esm/src/compile.js +10 -0
  144. package/dist/esm/src/conf.js +19 -0
  145. package/dist/esm/src/constants.js +5 -0
  146. package/dist/esm/src/domain.js +2 -0
  147. package/dist/esm/src/exceptions.js +15 -0
  148. package/dist/esm/src/index.js +160 -0
  149. package/dist/esm/src/model.js +255 -0
  150. package/dist/esm/src/parsers/convert-from-number.js +8 -0
  151. package/dist/esm/src/parsers/convert-from-string.js +14 -0
  152. package/dist/esm/src/parsers/index.js +2 -0
  153. package/dist/esm/src/schema/array.js +403 -0
  154. package/dist/esm/src/schema/boolean.js +465 -0
  155. package/dist/esm/src/schema/datetime.js +423 -0
  156. package/dist/esm/src/schema/index.js +3 -0
  157. package/dist/esm/src/schema/number.js +592 -0
  158. package/dist/esm/src/schema/object.js +464 -0
  159. package/dist/esm/src/schema/schema.js +728 -0
  160. package/dist/esm/src/schema/string.js +579 -0
  161. package/dist/esm/src/schema/types.js +1 -0
  162. package/dist/esm/src/schema/union.js +388 -0
  163. package/dist/esm/src/types.js +1 -0
  164. package/dist/esm/src/utils.js +175 -0
  165. package/dist/esm/src/validators/array.js +135 -0
  166. package/dist/esm/src/validators/boolean.js +35 -0
  167. package/dist/esm/src/validators/datetime.js +85 -0
  168. package/dist/esm/src/validators/number.js +162 -0
  169. package/dist/esm/src/validators/object.js +38 -0
  170. package/dist/esm/src/validators/schema.js +114 -0
  171. package/dist/esm/src/validators/string.js +174 -0
  172. package/dist/esm/src/validators/types.js +1 -0
  173. package/dist/esm/src/validators/union.js +38 -0
  174. package/dist/esm/src/validators/utils.js +120 -0
  175. package/package.json +48 -0
  176. package/src/adapter/fields/array.ts +31 -0
  177. package/src/adapter/fields/boolean.ts +48 -0
  178. package/src/adapter/fields/datetime.ts +49 -0
  179. package/src/adapter/fields/index.ts +72 -0
  180. package/src/adapter/fields/number.ts +49 -0
  181. package/src/adapter/fields/object.ts +49 -0
  182. package/src/adapter/fields/string.ts +49 -0
  183. package/src/adapter/fields/union.ts +49 -0
  184. package/src/adapter/index.ts +34 -0
  185. package/src/adapter/types.ts +261 -0
  186. package/src/compile.ts +14 -0
  187. package/src/conf.ts +27 -0
  188. package/src/constants.ts +9 -0
  189. package/src/domain.ts +3 -0
  190. package/src/exceptions.ts +17 -0
  191. package/src/index.ts +338 -0
  192. package/src/model.ts +501 -0
  193. package/src/parsers/convert-from-number.ts +13 -0
  194. package/src/parsers/convert-from-string.ts +19 -0
  195. package/src/parsers/index.ts +2 -0
  196. package/src/schema/array.ts +633 -0
  197. package/src/schema/boolean.ts +700 -0
  198. package/src/schema/datetime.ts +613 -0
  199. package/src/schema/index.ts +5 -0
  200. package/src/schema/number.ts +885 -0
  201. package/src/schema/object.ts +699 -0
  202. package/src/schema/schema.ts +1093 -0
  203. package/src/schema/string.ts +807 -0
  204. package/src/schema/types.ts +126 -0
  205. package/src/schema/union.ts +596 -0
  206. package/src/types.ts +13 -0
  207. package/src/utils.ts +322 -0
  208. package/src/validators/array.ts +164 -0
  209. package/src/validators/boolean.ts +46 -0
  210. package/src/validators/datetime.ts +113 -0
  211. package/src/validators/number.ts +188 -0
  212. package/src/validators/object.ts +55 -0
  213. package/src/validators/schema.ts +134 -0
  214. package/src/validators/string.ts +215 -0
  215. package/src/validators/types.ts +1 -0
  216. package/src/validators/union.ts +52 -0
  217. package/src/validators/utils.ts +200 -0
  218. package/tsconfig.json +9 -0
  219. package/tsconfig.types.json +10 -0
@@ -0,0 +1,960 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ function _export(target, all) {
6
+ for(var name in all)Object.defineProperty(target, name, {
7
+ enumerable: true,
8
+ get: all[name]
9
+ });
10
+ }
11
+ _export(exports, {
12
+ default: function() {
13
+ return NumberSchema;
14
+ },
15
+ number: function() {
16
+ return number;
17
+ }
18
+ });
19
+ var _schema = /*#__PURE__*/ _interop_require_default(require("./schema"));
20
+ var _conf = require("../conf");
21
+ var _constants = require("../constants");
22
+ var _utils = require("../utils");
23
+ var _number = require("../validators/number");
24
+ function _assert_this_initialized(self) {
25
+ if (self === void 0) {
26
+ throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
27
+ }
28
+ return self;
29
+ }
30
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
31
+ try {
32
+ var info = gen[key](arg);
33
+ var value = info.value;
34
+ } catch (error) {
35
+ reject(error);
36
+ return;
37
+ }
38
+ if (info.done) {
39
+ resolve(value);
40
+ } else {
41
+ Promise.resolve(value).then(_next, _throw);
42
+ }
43
+ }
44
+ function _async_to_generator(fn) {
45
+ return function() {
46
+ var self = this, args = arguments;
47
+ return new Promise(function(resolve, reject) {
48
+ var gen = fn.apply(self, args);
49
+ function _next(value) {
50
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
51
+ }
52
+ function _throw(err) {
53
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
54
+ }
55
+ _next(undefined);
56
+ });
57
+ };
58
+ }
59
+ function _class_call_check(instance, Constructor) {
60
+ if (!(instance instanceof Constructor)) {
61
+ throw new TypeError("Cannot call a class as a function");
62
+ }
63
+ }
64
+ function _defineProperties(target, props) {
65
+ for(var i = 0; i < props.length; i++){
66
+ var descriptor = props[i];
67
+ descriptor.enumerable = descriptor.enumerable || false;
68
+ descriptor.configurable = true;
69
+ if ("value" in descriptor) descriptor.writable = true;
70
+ Object.defineProperty(target, descriptor.key, descriptor);
71
+ }
72
+ }
73
+ function _create_class(Constructor, protoProps, staticProps) {
74
+ if (protoProps) _defineProperties(Constructor.prototype, protoProps);
75
+ if (staticProps) _defineProperties(Constructor, staticProps);
76
+ return Constructor;
77
+ }
78
+ function _define_property(obj, key, value) {
79
+ if (key in obj) {
80
+ Object.defineProperty(obj, key, {
81
+ value: value,
82
+ enumerable: true,
83
+ configurable: true,
84
+ writable: true
85
+ });
86
+ } else {
87
+ obj[key] = value;
88
+ }
89
+ return obj;
90
+ }
91
+ function _get(target, property, receiver) {
92
+ if (typeof Reflect !== "undefined" && Reflect.get) {
93
+ _get = Reflect.get;
94
+ } else {
95
+ _get = function get(target, property, receiver) {
96
+ var base = _super_prop_base(target, property);
97
+ if (!base) return;
98
+ var desc = Object.getOwnPropertyDescriptor(base, property);
99
+ if (desc.get) {
100
+ return desc.get.call(receiver || target);
101
+ }
102
+ return desc.value;
103
+ };
104
+ }
105
+ return _get(target, property, receiver || target);
106
+ }
107
+ function _get_prototype_of(o) {
108
+ _get_prototype_of = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o) {
109
+ return o.__proto__ || Object.getPrototypeOf(o);
110
+ };
111
+ return _get_prototype_of(o);
112
+ }
113
+ function _inherits(subClass, superClass) {
114
+ if (typeof superClass !== "function" && superClass !== null) {
115
+ throw new TypeError("Super expression must either be null or a function");
116
+ }
117
+ subClass.prototype = Object.create(superClass && superClass.prototype, {
118
+ constructor: {
119
+ value: subClass,
120
+ writable: true,
121
+ configurable: true
122
+ }
123
+ });
124
+ if (superClass) _set_prototype_of(subClass, superClass);
125
+ }
126
+ function _interop_require_default(obj) {
127
+ return obj && obj.__esModule ? obj : {
128
+ default: obj
129
+ };
130
+ }
131
+ function _possible_constructor_return(self, call) {
132
+ if (call && (_type_of(call) === "object" || typeof call === "function")) {
133
+ return call;
134
+ }
135
+ return _assert_this_initialized(self);
136
+ }
137
+ function _set_prototype_of(o, p) {
138
+ _set_prototype_of = Object.setPrototypeOf || function setPrototypeOf(o, p) {
139
+ o.__proto__ = p;
140
+ return o;
141
+ };
142
+ return _set_prototype_of(o, p);
143
+ }
144
+ function _super_prop_base(object, property) {
145
+ while(!Object.prototype.hasOwnProperty.call(object, property)){
146
+ object = _get_prototype_of(object);
147
+ if (object === null) break;
148
+ }
149
+ return object;
150
+ }
151
+ function _type_of(obj) {
152
+ "@swc/helpers - typeof";
153
+ return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
154
+ }
155
+ function _is_native_reflect_construct() {
156
+ if (typeof Reflect === "undefined" || !Reflect.construct) return false;
157
+ if (Reflect.construct.sham) return false;
158
+ if (typeof Proxy === "function") return true;
159
+ try {
160
+ Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
161
+ return true;
162
+ } catch (e) {
163
+ return false;
164
+ }
165
+ }
166
+ function _create_super(Derived) {
167
+ var hasNativeReflectConstruct = _is_native_reflect_construct();
168
+ return function _createSuperInternal() {
169
+ var Super = _get_prototype_of(Derived), result;
170
+ if (hasNativeReflectConstruct) {
171
+ var NewTarget = _get_prototype_of(this).constructor;
172
+ result = Reflect.construct(Super, arguments, NewTarget);
173
+ } else {
174
+ result = Super.apply(this, arguments);
175
+ }
176
+ return _possible_constructor_return(this, result);
177
+ };
178
+ }
179
+ function _ts_generator(thisArg, body) {
180
+ var f, y, t, g, _ = {
181
+ label: 0,
182
+ sent: function() {
183
+ if (t[0] & 1) throw t[1];
184
+ return t[1];
185
+ },
186
+ trys: [],
187
+ ops: []
188
+ };
189
+ return g = {
190
+ next: verb(0),
191
+ "throw": verb(1),
192
+ "return": verb(2)
193
+ }, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
194
+ return this;
195
+ }), g;
196
+ function verb(n) {
197
+ return function(v) {
198
+ return step([
199
+ n,
200
+ v
201
+ ]);
202
+ };
203
+ }
204
+ function step(op) {
205
+ if (f) throw new TypeError("Generator is already executing.");
206
+ while(_)try {
207
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
208
+ if (y = 0, t) op = [
209
+ op[0] & 2,
210
+ t.value
211
+ ];
212
+ switch(op[0]){
213
+ case 0:
214
+ case 1:
215
+ t = op;
216
+ break;
217
+ case 4:
218
+ _.label++;
219
+ return {
220
+ value: op[1],
221
+ done: false
222
+ };
223
+ case 5:
224
+ _.label++;
225
+ y = op[1];
226
+ op = [
227
+ 0
228
+ ];
229
+ continue;
230
+ case 7:
231
+ op = _.ops.pop();
232
+ _.trys.pop();
233
+ continue;
234
+ default:
235
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
236
+ _ = 0;
237
+ continue;
238
+ }
239
+ if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
240
+ _.label = op[1];
241
+ break;
242
+ }
243
+ if (op[0] === 6 && _.label < t[1]) {
244
+ _.label = t[1];
245
+ t = op;
246
+ break;
247
+ }
248
+ if (t && _.label < t[2]) {
249
+ _.label = t[2];
250
+ _.ops.push(op);
251
+ break;
252
+ }
253
+ if (t[2]) _.ops.pop();
254
+ _.trys.pop();
255
+ continue;
256
+ }
257
+ op = body.call(thisArg, _);
258
+ } catch (e) {
259
+ op = [
260
+ 6,
261
+ e
262
+ ];
263
+ y = 0;
264
+ } finally{
265
+ f = t = 0;
266
+ }
267
+ if (op[0] & 5) throw op[1];
268
+ return {
269
+ value: op[0] ? op[1] : void 0,
270
+ done: true
271
+ };
272
+ }
273
+ }
274
+ var NumberSchema = /*#__PURE__*/ function(Schema) {
275
+ "use strict";
276
+ _inherits(NumberSchema, Schema);
277
+ var _super = _create_super(NumberSchema);
278
+ function NumberSchema() {
279
+ _class_call_check(this, NumberSchema);
280
+ var _this;
281
+ _this = _super.apply(this, arguments);
282
+ _define_property(_assert_this_initialized(_this), "__is", void 0);
283
+ _define_property(_assert_this_initialized(_this), "__integer", void 0);
284
+ _define_property(_assert_this_initialized(_this), "__maxDigits", void 0);
285
+ _define_property(_assert_this_initialized(_this), "__decimalPlaces", void 0);
286
+ _define_property(_assert_this_initialized(_this), "__max", void 0);
287
+ _define_property(_assert_this_initialized(_this), "__min", void 0);
288
+ _define_property(_assert_this_initialized(_this), "__allowNegative", void 0);
289
+ _define_property(_assert_this_initialized(_this), "__allowPositive", void 0);
290
+ return _this;
291
+ }
292
+ _create_class(NumberSchema, [
293
+ {
294
+ key: "__transformToAdapter",
295
+ value: function __transformToAdapter(options) {
296
+ var _this = this;
297
+ return _async_to_generator(function() {
298
+ return _ts_generator(this, function(_state) {
299
+ return [
300
+ 2,
301
+ (0, _utils.defaultTransformToAdapter)(function() {
302
+ var _ref = _async_to_generator(function(adapter) {
303
+ return _ts_generator(this, function(_state) {
304
+ return [
305
+ 2,
306
+ (0, _utils.defaultTransform)('number', _this, adapter, adapter.number, function() {
307
+ return {
308
+ is: _this.__is,
309
+ min: _this.__min,
310
+ allowNegative: _this.__allowNegative,
311
+ allowPositive: _this.__allowPositive,
312
+ max: _this.__max,
313
+ integer: _this.__integer,
314
+ optional: _this.__optional,
315
+ nullable: _this.__nullable,
316
+ maxDigits: _this.__maxDigits,
317
+ decimalPlaces: _this.__decimalPlaces,
318
+ parsers: {
319
+ nullable: _this.__nullable.allow,
320
+ optional: _this.__optional.allow
321
+ }
322
+ };
323
+ }, {
324
+ max: _number.max,
325
+ min: _number.min
326
+ }, {
327
+ validatorsIfFallbackOrNotSupported: (0, _number.numberValidation)(),
328
+ shouldAddStringVersion: options.shouldAddStringVersion,
329
+ // eslint-disable-next-line ts/require-await
330
+ fallbackIfNotSupported: /*#__PURE__*/ _async_to_generator(function() {
331
+ return _ts_generator(this, function(_state) {
332
+ return [
333
+ 2,
334
+ []
335
+ ];
336
+ });
337
+ })
338
+ })
339
+ ];
340
+ });
341
+ });
342
+ return function(adapter) {
343
+ return _ref.apply(this, arguments);
344
+ };
345
+ }(), _this.__transformedSchemas, options, 'number')
346
+ ];
347
+ });
348
+ })();
349
+ }
350
+ },
351
+ {
352
+ /**
353
+ * This let's you refine the schema with custom validations. This is useful when you want to validate something that is not supported by default by the schema adapter.
354
+ *
355
+ * @example
356
+ * ```typescript
357
+ * import * as p from '@palmares/schemas';
358
+ *
359
+ * const numberSchema = p.number().refine((value) => {
360
+ * if (value < 0) return { code: 'invalid_number', message: 'The number should be greater than 0' };
361
+ * });
362
+ *
363
+ * const { errors, parsed } = await numberSchema.parse(-1);
364
+ *
365
+ * console.log(errors); // [{ isValid: false, code: 'invalid_number', message: 'The number should be greater than 0', path: [] }]
366
+ * ```
367
+ *
368
+ * @param refinementCallback - The callback that will be called to validate the value.
369
+ * @param options - Options for the refinement.
370
+ * @param options.isAsync - Whether the callback is async or not. Defaults to true.
371
+ *
372
+ * @returns The schema.
373
+ */ key: "refine",
374
+ value: function refine(refinementCallback) {
375
+ return _get(_get_prototype_of(NumberSchema.prototype), "refine", this).call(this, refinementCallback);
376
+ }
377
+ },
378
+ {
379
+ /**
380
+ * Allows the value to be either undefined or null.
381
+ *
382
+ * @example
383
+ * ```typescript
384
+ * import * as p from '@palmares/schemas';
385
+ *
386
+ * const numberSchema = p.number().optional();
387
+ *
388
+ * const { errors, parsed } = await numberSchema.parse(undefined);
389
+ *
390
+ * console.log(parsed); // undefined
391
+ *
392
+ * const { errors, parsed } = await numberSchema.parse(null);
393
+ *
394
+ * console.log(parsed); // null
395
+ *
396
+ * const { errors, parsed } = await numberSchema.parse(1);
397
+ *
398
+ * console.log(parsed); // 1
399
+ * ```
400
+ *
401
+ * @returns - The schema we are working with.
402
+ */ key: "optional",
403
+ value: function optional(options) {
404
+ return _get(_get_prototype_of(NumberSchema.prototype), "optional", this).call(this, options);
405
+ }
406
+ },
407
+ {
408
+ /**
409
+ * Allows the value to be null and ONLY null. You can also use this function to set a custom message when the value is NULL by setting
410
+ * the { message: 'Your custom message', allow: false } on the options.
411
+ *
412
+ * @example
413
+ * ```typescript
414
+ * import * as p from '@palmares/schemas';
415
+ *
416
+ * const numberSchema = p.number().nullable();
417
+ *
418
+ * const { errors, parsed } = await numberSchema.parse(null);
419
+ *
420
+ * console.log(parsed); // null
421
+ *
422
+ * const { errors, parsed } = await numberSchema.parse(undefined);
423
+ *
424
+ * console.log(errors); // [{ isValid: false, code: 'invalid_type', message: 'Invalid type', path: [] }]
425
+ * ```
426
+ *
427
+ * @param options - The options for the nullable function.
428
+ * @param options.message - The message to be shown when the value is not null. Defaults to 'Cannot be null'.
429
+ * @param options.allow - Whether the value can be null or not. Defaults to true.
430
+ *
431
+ * @returns The schema.
432
+ */ key: "nullable",
433
+ value: function nullable(options) {
434
+ return _get(_get_prototype_of(NumberSchema.prototype), "nullable", this).call(this, options);
435
+ }
436
+ },
437
+ {
438
+ /**
439
+ * This method will remove the value from the representation of the schema. If the value is undefined it will keep that way
440
+ * otherwise it will set the value to undefined after it's validated.
441
+ * This is used in conjunction with the {@link data} function, the {@link parse} function or {@link validate}
442
+ * function. This will remove the value from the representation of the schema.
443
+ *
444
+ * By default, the value will be removed just from the representation, in other words, when you call the {@link data} function.
445
+ * But if you want to remove the value from the internal representation, you can pass the argument `toInternal` as true.
446
+ * Then if you still want to remove the value from the representation, you will need to pass the argument `toRepresentation` as true as well.
447
+ *
448
+ * @example
449
+ * ```typescript
450
+ * import * as p from '@palmares/schemas';
451
+ *
452
+ * const userSchema = p.object({
453
+ * id: p.number().optional(),
454
+ * name: p.string(),
455
+ * password: p.string().omit()
456
+ * });
457
+ *
458
+ * const user = await userSchema.data({
459
+ * id: 1,
460
+ * name: 'John Doe',
461
+ * password: '123456'
462
+ * });
463
+ *
464
+ * console.log(user); // { id: 1, name: 'John Doe' }
465
+ * ```
466
+ *
467
+ *
468
+ * @param args - By default, the value will be removed just from the representation, in other words, when you call the {@link data} function.
469
+ * But if you want to remove the value from the internal representation, you can pass the argument `toInternal` as true.
470
+ * Then if you still want to remove the value from the representation, you will need to pass the argument `toRepresentation` as true as well.
471
+ *
472
+ * @returns The schema.
473
+ */ key: "omit",
474
+ value: function omit(args) {
475
+ return _get(_get_prototype_of(NumberSchema.prototype), "omit", this).call(this, args);
476
+ }
477
+ },
478
+ {
479
+ /**
480
+ * This function is used in conjunction with the {@link validate} function. It's used to save a value to an external source
481
+ * like a database. You should always return the schema after you save the value, that way we will always have the correct type
482
+ * of the schema after the save operation.
483
+ *
484
+ * You can use the {@link toRepresentation} function to transform and clean the value it returns after the save.
485
+ *
486
+ * @example
487
+ * ```typescript
488
+ * import * as p from '@palmares/schemas';
489
+ *
490
+ * import { User } from './models';
491
+ *
492
+ * const userSchema = p.object({
493
+ * id: p.number().optional(),
494
+ * name: p.string(),
495
+ * email: p.string().email(),
496
+ * }).onSave(async (value) => {
497
+ * // Create or update the user on the database using palmares models or any other library of your choice.
498
+ * if (value.id)
499
+ * await User.default.set(value, { search: { id: value.id } });
500
+ * else
501
+ * await User.default.set(value);
502
+ *
503
+ * return value;
504
+ * });
505
+ *
506
+ *
507
+ * // Then, on your controller, do something like this:
508
+ * const { isValid, save, errors } = await userSchema.validate(req.body);
509
+ * if (isValid) {
510
+ * const savedValue = await save();
511
+ * return Response.json(savedValue, { status: 201 });
512
+ * }
513
+ *
514
+ * return Response.json({ errors }, { status: 400 });
515
+ * ```
516
+ *
517
+ * @param callback - The callback that will be called to save the value on an external source.
518
+ *
519
+ * @returns The schema.
520
+ */ key: "onSave",
521
+ value: function onSave(callback) {
522
+ return _get(_get_prototype_of(NumberSchema.prototype), "onSave", this).call(this, callback);
523
+ }
524
+ },
525
+ {
526
+ /**
527
+ * This function is used to add a default value to the schema. If the value is either undefined or null, the default value will be used.
528
+ *
529
+ * @example
530
+ * ```typescript
531
+ * import * as p from '@palmares/schemas';
532
+ *
533
+ * const numberSchema = p.number().default(0);
534
+ *
535
+ * const { errors, parsed } = await numberSchema.parse(undefined);
536
+ *
537
+ * console.log(parsed); // 0
538
+ * ```
539
+ */ key: "default",
540
+ value: function _default(defaultValueOrFunction) {
541
+ return _get(_get_prototype_of(NumberSchema.prototype), "default", this).call(this, defaultValueOrFunction);
542
+ }
543
+ },
544
+ {
545
+ /**
546
+ * This function let's you customize the schema your own way. After we translate the schema on the adapter we call this function to let you customize
547
+ * the custom schema your own way. Our API does not support passthrough? No problem, you can use this function to customize the zod schema.
548
+ *
549
+ * @example
550
+ * ```typescript
551
+ * import * as p from '@palmares/schemas';
552
+ *
553
+ * const numberSchema = p.number().extends((schema) => {
554
+ * return schema.nonnegative();
555
+ * });
556
+ *
557
+ * const { errors, parsed } = await numberSchema.parse(-1);
558
+ *
559
+ * console.log(errors); // [{ isValid: false, code: 'nonnegative', message: 'The number should be nonnegative', path: [] }]
560
+ * ```
561
+ *
562
+ * @param callback - The callback that will be called to customize the schema.
563
+ * @param toStringCallback - The callback that will be called to transform the schema to a string when you want to compile the underlying schema
564
+ * to a string so you can save it for future runs.
565
+ *
566
+ * @returns The schema.
567
+ */ key: "extends",
568
+ value: function _extends(callback, toStringCallback) {
569
+ return _get(_get_prototype_of(NumberSchema.prototype), "extends", this).call(this, callback, toStringCallback);
570
+ }
571
+ },
572
+ {
573
+ /**
574
+ * This function is used to transform the value to the representation of the schema. When using the {@link data} function. With this function you have full
575
+ * control to add data cleaning for example, transforming the data and whatever. Another use case is when you want to return deeply nested recursive data.
576
+ * The schema maps to itself.
577
+ *
578
+ * @example
579
+ * ```typescript
580
+ * import * as p from '@palmares/schemas';
581
+ *
582
+ * const recursiveSchema = p.object({
583
+ * id: p.number().optional(),
584
+ * name: p.string(),
585
+ * }).toRepresentation(async (value) => {
586
+ * return {
587
+ * id: value.id,
588
+ * name: value.name,
589
+ * children: await Promise.all(value.children.map(async (child) => await recursiveSchema.data(child)))
590
+ * }
591
+ * });
592
+ *
593
+ * const data = await recursiveSchema.data({
594
+ * id: 1,
595
+ * name: 'John Doe',
596
+ * });
597
+ * ```
598
+ *
599
+ * @example
600
+ * ```
601
+ * import * as p from '@palmares/schemas';
602
+ *
603
+ * const colorToRGBSchema = p.string().toRepresentation(async (value) => {
604
+ * switch (value) {
605
+ * case 'red': return { r: 255, g: 0, b: 0 };
606
+ * case 'green': return { r: 0, g: 255, b: 0 };
607
+ * case 'blue': return { r: 0, g: 0, b: 255 };
608
+ * default: return { r: 0, g: 0, b: 0 };
609
+ * }
610
+ * });
611
+ * ```
612
+ * @param toRepresentationCallback - The callback that will be called to transform the value to the representation.
613
+ *
614
+ * @returns The schema with a new return type
615
+ */ key: "toRepresentation",
616
+ value: function toRepresentation(toRepresentationCallback) {
617
+ return _get(_get_prototype_of(NumberSchema.prototype), "toRepresentation", this).call(this, toRepresentationCallback);
618
+ }
619
+ },
620
+ {
621
+ /**
622
+ * This function is used to transform the value to the internal representation of the schema. This is useful when you want to transform the value
623
+ * to a type that the schema adapter can understand. For example, you might want to transform a string to a date. This is the function you use.
624
+ *
625
+ * @example
626
+ * ```typescript
627
+ * import * as p from '@palmares/schemas';
628
+ *
629
+ * const dateSchema = p.string().toInternal((value) => {
630
+ * return new Date(value);
631
+ * });
632
+ *
633
+ * const date = await dateSchema.parse('2021-01-01');
634
+ *
635
+ * console.log(date); // Date object
636
+ *
637
+ * const rgbToColorSchema = p.object({
638
+ * r: p.number().min(0).max(255),
639
+ * g: p.number().min(0).max(255),
640
+ * b: p.number().min(0).max(255),
641
+ * }).toInternal(async (value) => {
642
+ * if (value.r === 255 && value.g === 0 && value.b === 0) return 'red';
643
+ * if (value.r === 0 && value.g === 255 && value.b === 0) return 'green';
644
+ * if (value.r === 0 && value.g === 0 && value.b === 255) return 'blue';
645
+ * return `rgb(${value.r}, ${value.g}, ${value.b})`;
646
+ * });
647
+ * ```
648
+ *
649
+ * @param toInternalCallback - The callback that will be called to transform the value to the internal representation.
650
+ *
651
+ * @returns The schema with a new return type.
652
+ */ key: "toInternal",
653
+ value: function toInternal(toInternalCallback) {
654
+ return _get(_get_prototype_of(NumberSchema.prototype), "toInternal", this).call(this, toInternalCallback);
655
+ }
656
+ },
657
+ {
658
+ /**
659
+ * Called before the validation of the schema. Let's say that you want to validate a date that might receive a string, you can convert that string to a date
660
+ * here BEFORE the validation. This pretty much transforms the value to a type that the schema adapter can understand.
661
+ *
662
+ * @example
663
+ * ```
664
+ * import * as p from '@palmares/schemas';
665
+ * import * as z from 'zod';
666
+ *
667
+ * const customRecordToMapSchema = p.schema().appendSchema(z.map()).toValidate(async (value) => {
668
+ * return new Map(value); // Before validating we transform the value to a map.
669
+ * });
670
+ *
671
+ * const { errors, parsed } = await customRecordToMapSchema.parse({ key: 'value' });
672
+ * ```
673
+ *
674
+ * @param toValidateCallback - The callback that will be called to validate the value.
675
+ *
676
+ * @returns The schema with a new return type.
677
+ */ key: "toValidate",
678
+ value: function toValidate(toValidateCallback) {
679
+ return _get(_get_prototype_of(NumberSchema.prototype), "toValidate", this).call(this, toValidateCallback);
680
+ }
681
+ },
682
+ {
683
+ /**
684
+ * Defines a list of numbers that are allowed, it's not a range but the actual numbers that are allowed, it's useful
685
+ * when you want to allow only specific set of numbers.
686
+ *
687
+ * @example
688
+ * ```typescript
689
+ * import * as p from '@palmares/schema';
690
+ *
691
+ * const schema = p.number().is([1, 2, 3]);
692
+ *
693
+ * schema.parse(1); // { errors: [], parsed: 1 }
694
+ * schema.parse(2); // { errors: [], parsed: 2 }
695
+ * schema.parse(3); // { errors: [], parsed: 3 }
696
+ * schema.parse(4); // { errors: [{ code: 'is', message: 'The value should be equal to 1,2,3' }], parsed: 4 }
697
+ * ```
698
+ *
699
+ * @param value - The list of numbers that are allowed
700
+ *
701
+ * @returns - The schema instance
702
+ */ key: "is",
703
+ value: function is(value) {
704
+ this.__is = {
705
+ value: value,
706
+ message: "The value should be equal to ".concat(value.join(','))
707
+ };
708
+ return this;
709
+ }
710
+ },
711
+ {
712
+ /**
713
+ * Allows only numbers that are less than the value passed. If you want to allow the number to be equal to the value, you can pass the option `inclusive` as `true`.
714
+ * Otherwise, it will only allow numbers less than the value.
715
+ *
716
+ * @example
717
+ * ```typescript
718
+ * import * as p from '@palmares/schema';
719
+ *
720
+ * const schema = p.number().max(10);
721
+ *
722
+ * schema.parse(10); // { errors: [{ code: 'max', message: 'The number should be less than 10' }], parsed: 10 }
723
+ * schema.parse(9); // { errors: [], parsed: 9 }
724
+ *
725
+ * const schema = p.number().max(10, { inclusive: true });
726
+ *
727
+ * schema.parse(10); // { errors: [], parsed: 10 }
728
+ * ```
729
+ *
730
+ * @param value - The value to compare with the number
731
+ * @param options - The options to be passed to the validation
732
+ * @param options.inclusive - If you want to allow the number to be equal to the value, you can pass this option
733
+ * @param options.message - The message to be returned if the validation fails
734
+ *
735
+ * @returns - The schema instance
736
+ */ key: "max",
737
+ value: function max(value, options) {
738
+ var inclusive = typeof (options === null || options === void 0 ? void 0 : options.inclusive) === 'boolean' ? options.inclusive : false;
739
+ var message = typeof (options === null || options === void 0 ? void 0 : options.message) === 'string' ? options.message : (0, _constants.DEFAULT_NUMBER_MAX_EXCEPTION)(value, inclusive);
740
+ this.__max = {
741
+ value: value,
742
+ inclusive: inclusive,
743
+ message: message
744
+ };
745
+ return this;
746
+ }
747
+ },
748
+ {
749
+ /**
750
+ * This method will validate if the number is greater than the value passed. If you want to allow the number to be equal to the value, you can pass the option `inclusive` as `true`.
751
+ * Otherwise, it will only allow numbers greater than the value.
752
+ *
753
+ * @example
754
+ * ```typescript
755
+ * import * as p from '@palmares/schema';
756
+ *
757
+ * const schema = p.number().min(10);
758
+ *
759
+ * schema.parse(10); // { errors: [], parsed: 10 }
760
+ * schema.parse(9); // { errors: [{ code: 'min', message: 'The number should be greater than 10' }], parsed: 9 }
761
+ *
762
+ * const schema = p.number().min(10, { inclusive: true });
763
+ *
764
+ * schema.parse(10); // { errors: [], parsed: 10 }
765
+ * ```
766
+ *
767
+ * @param value - The value to compare with the number
768
+ * @param options - The options to be passed to the validation
769
+ * @param options.inclusive - If you want to allow the number to be equal to the value, you can pass this option
770
+ * @param options.message - The message to be returned if the validation fails
771
+ *
772
+ * @returns - The schema instance
773
+ */ key: "min",
774
+ value: function min(value, options) {
775
+ var inclusive = typeof (options === null || options === void 0 ? void 0 : options.inclusive) === 'boolean' ? options.inclusive : false;
776
+ var message = typeof (options === null || options === void 0 ? void 0 : options.message) === 'string' ? options.message : (0, _constants.DEFAULT_NUMBER_MIN_EXCEPTION)(value, inclusive);
777
+ this.__min = {
778
+ value: value,
779
+ inclusive: inclusive,
780
+ message: message
781
+ };
782
+ return this;
783
+ }
784
+ },
785
+ {
786
+ /**
787
+ * Allows only negative numbers. If you want to allow zero, you can pass the option `allowZero` as `true`. Otherwise, it will only allow negative numbers.
788
+ *
789
+ * @example
790
+ * ```typescript
791
+ * import * as p from '@palmares/schema';
792
+ *
793
+ * const schema = p.number().negative();
794
+ *
795
+ * schema.parse(-10); // { errors: [], parsed: -10 }
796
+ * schema.parse(0); // { errors: [{ code: 'negative', message: 'The number should be negative' }], parsed: 0 }
797
+ *
798
+ * const schema = p.number().negative({ allowZero: true });
799
+ *
800
+ * schema.parse(0); // { errors: [], parsed: 0 }
801
+ * ```
802
+ *
803
+ * @param options - The options to be passed to the validation
804
+ * @param options.allowZero - If you want to allow zero, you can pass this option as `true`. Otherwise, it will only allow negative numbers.
805
+ * @param options.message - The message to be returned if the validation fails
806
+ *
807
+ * @returns - The schema instance
808
+ */ key: "negative",
809
+ value: function negative(options) {
810
+ var allowZero = typeof (options === null || options === void 0 ? void 0 : options.allowZero) === 'boolean' ? options.allowZero : true;
811
+ var message = typeof (options === null || options === void 0 ? void 0 : options.message) === 'string' ? options.message : (0, _constants.DEFAULT_NUMBER_NEGATIVE_EXCEPTION)(allowZero);
812
+ this.__allowNegative = {
813
+ allowZero: allowZero,
814
+ message: message
815
+ };
816
+ return this;
817
+ }
818
+ },
819
+ {
820
+ /**
821
+ * Allows only positive numbers. If you want to allow zero, you can pass the option `allowZero` as `true`. Otherwise, it will only allow positive numbers greater than zero.
822
+ *
823
+ * @example
824
+ * ```typescript
825
+ * import * as p from '@palmares/schema';
826
+ *
827
+ * const schema = p.number().positive();
828
+ *
829
+ * schema.parse(10); // { errors: [], parsed: 10 }
830
+ * schema.parse(0); // { errors: [{ code: 'positive', message: 'The number should be positive' }], parsed: 0 }
831
+ *
832
+ * const schema = p.number().positive({ allowZero: true });
833
+ * schema.parse(0); // { errors: [], parsed: 0 }
834
+ * ```
835
+ *
836
+ * @param options - The options to be passed to the validation
837
+ * @param options.allowZero - If you want to allow zero, you can pass this option as `true`. Otherwise, it will only allow positive numbers greater than zero.
838
+ * @param options.message - The message to be returned if the validation fails
839
+ *
840
+ * @returns - The schema instance
841
+ */ key: "positive",
842
+ value: function positive(options) {
843
+ var allowZero = typeof (options === null || options === void 0 ? void 0 : options.allowZero) === 'boolean' ? options.allowZero : true;
844
+ var message = typeof (options === null || options === void 0 ? void 0 : options.message) === 'string' ? options.message : (0, _constants.DEFAULT_NUMBER_NEGATIVE_EXCEPTION)(allowZero);
845
+ this.__allowPositive = {
846
+ allowZero: allowZero,
847
+ message: message
848
+ };
849
+ return this;
850
+ }
851
+ },
852
+ {
853
+ /**
854
+ * This method will validate the number to have the exact number of decimal places. It's usually useful for decimal numbers like currencies.
855
+ *
856
+ * @example
857
+ * ```
858
+ * const schema = number().decimalPlaces(2);
859
+ *
860
+ * schema.parse(10.00); // { errors: [], parsed: 10.00}
861
+ *
862
+ * schema.parse(10.000); // { errors: [{ code: 'decimal_places', message: 'The number should have 2 decimal places' }], parsed: 10.000}
863
+ * ```
864
+ *
865
+ * @param value - The number of decimal places.
866
+ * @param options - The options.
867
+ * @param options.message - The message to show if the validation fails.
868
+ *
869
+ * @returns The schema so you can chain other methods.
870
+ */ key: "decimalPlaces",
871
+ value: function decimalPlaces(value, options) {
872
+ var message = typeof (options === null || options === void 0 ? void 0 : options.message) === 'string' ? options.message : "The number should have ".concat(value, " decimal places");
873
+ this.__decimalPlaces = {
874
+ value: value,
875
+ message: message
876
+ };
877
+ return this;
878
+ }
879
+ },
880
+ {
881
+ /**
882
+ * This method will validate the number to have at most the number of digits specified. If used in conjunction with {@link decimalPlaces}, this number should be bigger than the
883
+ * value of the decimal places.
884
+ *
885
+ * Think about that
886
+ *
887
+ * - If you have a number with 2 decimal places, the number 10.00 has 4 digits and 2 decimal places.
888
+ * - The number 10.000 has 5 digits and 3 decimal places.
889
+ *
890
+ * @example
891
+ * ```
892
+ * const schema = number().maxDigits(4);
893
+ *
894
+ * schema.parse(10); // { errors: [], parsed: 10}
895
+ * schema.parse(100); // { errors: [], parsed: 100}
896
+ * schema.parse(1000); // { errors: [], parsed: 1000}
897
+ * ```
898
+ *
899
+ * @param value - The maximum number of digits, counting the digits before and after the decimal point.
900
+ * @param options - Custom options for the validation.
901
+ * @param options.message - The message to show if the validation fails.
902
+ *
903
+ * @returns - The schema so you can chain other methods.
904
+ */ key: "maxDigits",
905
+ value: function maxDigits(value, options) {
906
+ var message = typeof (options === null || options === void 0 ? void 0 : options.message) === 'string' ? options.message : "The number should have at most ".concat(value, " digits");
907
+ this.__maxDigits = {
908
+ value: value,
909
+ message: message
910
+ };
911
+ return this;
912
+ }
913
+ },
914
+ {
915
+ /**
916
+ * With this method we will validate if the number is an integer. If it's not, we will return an error.
917
+ *
918
+ * @example
919
+ * ```typescript
920
+ * import * as p from '@palmares/schema';
921
+ *
922
+ * const schema = p.number().integer();
923
+ *
924
+ * schema.parse(10); // { errors: [], parsed: 10 }
925
+ * schema.parse(10.1); // { errors: [{ code: 'integer', message: 'The number should be an integer' }], parsed: 10.1 }
926
+ * ```
927
+ *
928
+ * @param options - The options to be passed to the validation
929
+ * @param options.message - The message to be returned if the validation fails
930
+ *
931
+ * @returns - The schema instance
932
+ */ key: "integer",
933
+ value: function integer(options) {
934
+ var message = typeof (options === null || options === void 0 ? void 0 : options.message) === 'string' ? options.message : (0, _constants.DEFAULT_NUMBER_INTEGER_EXCEPTION)();
935
+ this.__integer = {
936
+ message: message
937
+ };
938
+ return this;
939
+ }
940
+ }
941
+ ], [
942
+ {
943
+ key: "new",
944
+ value: function _new() {
945
+ var returnValue = new NumberSchema();
946
+ var adapterInstance = (0, _conf.getDefaultAdapter)();
947
+ returnValue.__transformedSchemas[adapterInstance.constructor.name] = {
948
+ transformed: false,
949
+ adapter: adapterInstance,
950
+ schemas: []
951
+ };
952
+ return returnValue;
953
+ }
954
+ }
955
+ ]);
956
+ return NumberSchema;
957
+ }(_schema.default);
958
+ var number = function() {
959
+ return NumberSchema.new();
960
+ };