@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,948 @@
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 StringSchema;
14
+ },
15
+ string: function() {
16
+ return string;
17
+ }
18
+ });
19
+ var _schema = /*#__PURE__*/ _interop_require_default(require("./schema"));
20
+ var _conf = require("../conf");
21
+ var _utils = require("../utils");
22
+ var _string = require("../validators/string");
23
+ function _assert_this_initialized(self) {
24
+ if (self === void 0) {
25
+ throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
26
+ }
27
+ return self;
28
+ }
29
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
30
+ try {
31
+ var info = gen[key](arg);
32
+ var value = info.value;
33
+ } catch (error) {
34
+ reject(error);
35
+ return;
36
+ }
37
+ if (info.done) {
38
+ resolve(value);
39
+ } else {
40
+ Promise.resolve(value).then(_next, _throw);
41
+ }
42
+ }
43
+ function _async_to_generator(fn) {
44
+ return function() {
45
+ var self = this, args = arguments;
46
+ return new Promise(function(resolve, reject) {
47
+ var gen = fn.apply(self, args);
48
+ function _next(value) {
49
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
50
+ }
51
+ function _throw(err) {
52
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
53
+ }
54
+ _next(undefined);
55
+ });
56
+ };
57
+ }
58
+ function _class_call_check(instance, Constructor) {
59
+ if (!(instance instanceof Constructor)) {
60
+ throw new TypeError("Cannot call a class as a function");
61
+ }
62
+ }
63
+ function _defineProperties(target, props) {
64
+ for(var i = 0; i < props.length; i++){
65
+ var descriptor = props[i];
66
+ descriptor.enumerable = descriptor.enumerable || false;
67
+ descriptor.configurable = true;
68
+ if ("value" in descriptor) descriptor.writable = true;
69
+ Object.defineProperty(target, descriptor.key, descriptor);
70
+ }
71
+ }
72
+ function _create_class(Constructor, protoProps, staticProps) {
73
+ if (protoProps) _defineProperties(Constructor.prototype, protoProps);
74
+ if (staticProps) _defineProperties(Constructor, staticProps);
75
+ return Constructor;
76
+ }
77
+ function _define_property(obj, key, value) {
78
+ if (key in obj) {
79
+ Object.defineProperty(obj, key, {
80
+ value: value,
81
+ enumerable: true,
82
+ configurable: true,
83
+ writable: true
84
+ });
85
+ } else {
86
+ obj[key] = value;
87
+ }
88
+ return obj;
89
+ }
90
+ function _get(target, property, receiver) {
91
+ if (typeof Reflect !== "undefined" && Reflect.get) {
92
+ _get = Reflect.get;
93
+ } else {
94
+ _get = function get(target, property, receiver) {
95
+ var base = _super_prop_base(target, property);
96
+ if (!base) return;
97
+ var desc = Object.getOwnPropertyDescriptor(base, property);
98
+ if (desc.get) {
99
+ return desc.get.call(receiver || target);
100
+ }
101
+ return desc.value;
102
+ };
103
+ }
104
+ return _get(target, property, receiver || target);
105
+ }
106
+ function _get_prototype_of(o) {
107
+ _get_prototype_of = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o) {
108
+ return o.__proto__ || Object.getPrototypeOf(o);
109
+ };
110
+ return _get_prototype_of(o);
111
+ }
112
+ function _inherits(subClass, superClass) {
113
+ if (typeof superClass !== "function" && superClass !== null) {
114
+ throw new TypeError("Super expression must either be null or a function");
115
+ }
116
+ subClass.prototype = Object.create(superClass && superClass.prototype, {
117
+ constructor: {
118
+ value: subClass,
119
+ writable: true,
120
+ configurable: true
121
+ }
122
+ });
123
+ if (superClass) _set_prototype_of(subClass, superClass);
124
+ }
125
+ function _interop_require_default(obj) {
126
+ return obj && obj.__esModule ? obj : {
127
+ default: obj
128
+ };
129
+ }
130
+ function _possible_constructor_return(self, call) {
131
+ if (call && (_type_of(call) === "object" || typeof call === "function")) {
132
+ return call;
133
+ }
134
+ return _assert_this_initialized(self);
135
+ }
136
+ function _set_prototype_of(o, p) {
137
+ _set_prototype_of = Object.setPrototypeOf || function setPrototypeOf(o, p) {
138
+ o.__proto__ = p;
139
+ return o;
140
+ };
141
+ return _set_prototype_of(o, p);
142
+ }
143
+ function _super_prop_base(object, property) {
144
+ while(!Object.prototype.hasOwnProperty.call(object, property)){
145
+ object = _get_prototype_of(object);
146
+ if (object === null) break;
147
+ }
148
+ return object;
149
+ }
150
+ function _type_of(obj) {
151
+ "@swc/helpers - typeof";
152
+ return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
153
+ }
154
+ function _is_native_reflect_construct() {
155
+ if (typeof Reflect === "undefined" || !Reflect.construct) return false;
156
+ if (Reflect.construct.sham) return false;
157
+ if (typeof Proxy === "function") return true;
158
+ try {
159
+ Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
160
+ return true;
161
+ } catch (e) {
162
+ return false;
163
+ }
164
+ }
165
+ function _create_super(Derived) {
166
+ var hasNativeReflectConstruct = _is_native_reflect_construct();
167
+ return function _createSuperInternal() {
168
+ var Super = _get_prototype_of(Derived), result;
169
+ if (hasNativeReflectConstruct) {
170
+ var NewTarget = _get_prototype_of(this).constructor;
171
+ result = Reflect.construct(Super, arguments, NewTarget);
172
+ } else {
173
+ result = Super.apply(this, arguments);
174
+ }
175
+ return _possible_constructor_return(this, result);
176
+ };
177
+ }
178
+ function _ts_generator(thisArg, body) {
179
+ var f, y, t, g, _ = {
180
+ label: 0,
181
+ sent: function() {
182
+ if (t[0] & 1) throw t[1];
183
+ return t[1];
184
+ },
185
+ trys: [],
186
+ ops: []
187
+ };
188
+ return g = {
189
+ next: verb(0),
190
+ "throw": verb(1),
191
+ "return": verb(2)
192
+ }, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
193
+ return this;
194
+ }), g;
195
+ function verb(n) {
196
+ return function(v) {
197
+ return step([
198
+ n,
199
+ v
200
+ ]);
201
+ };
202
+ }
203
+ function step(op) {
204
+ if (f) throw new TypeError("Generator is already executing.");
205
+ while(_)try {
206
+ 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;
207
+ if (y = 0, t) op = [
208
+ op[0] & 2,
209
+ t.value
210
+ ];
211
+ switch(op[0]){
212
+ case 0:
213
+ case 1:
214
+ t = op;
215
+ break;
216
+ case 4:
217
+ _.label++;
218
+ return {
219
+ value: op[1],
220
+ done: false
221
+ };
222
+ case 5:
223
+ _.label++;
224
+ y = op[1];
225
+ op = [
226
+ 0
227
+ ];
228
+ continue;
229
+ case 7:
230
+ op = _.ops.pop();
231
+ _.trys.pop();
232
+ continue;
233
+ default:
234
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
235
+ _ = 0;
236
+ continue;
237
+ }
238
+ if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
239
+ _.label = op[1];
240
+ break;
241
+ }
242
+ if (op[0] === 6 && _.label < t[1]) {
243
+ _.label = t[1];
244
+ t = op;
245
+ break;
246
+ }
247
+ if (t && _.label < t[2]) {
248
+ _.label = t[2];
249
+ _.ops.push(op);
250
+ break;
251
+ }
252
+ if (t[2]) _.ops.pop();
253
+ _.trys.pop();
254
+ continue;
255
+ }
256
+ op = body.call(thisArg, _);
257
+ } catch (e) {
258
+ op = [
259
+ 6,
260
+ e
261
+ ];
262
+ y = 0;
263
+ } finally{
264
+ f = t = 0;
265
+ }
266
+ if (op[0] & 5) throw op[1];
267
+ return {
268
+ value: op[0] ? op[1] : void 0,
269
+ done: true
270
+ };
271
+ }
272
+ }
273
+ var StringSchema = /*#__PURE__*/ function(Schema) {
274
+ "use strict";
275
+ _inherits(StringSchema, Schema);
276
+ var _super = _create_super(StringSchema);
277
+ function StringSchema() {
278
+ _class_call_check(this, StringSchema);
279
+ var _this;
280
+ _this = _super.apply(this, arguments);
281
+ _define_property(_assert_this_initialized(_this), "__is", void 0);
282
+ _define_property(_assert_this_initialized(_this), "__email", void 0);
283
+ _define_property(_assert_this_initialized(_this), "__uuid", void 0);
284
+ _define_property(_assert_this_initialized(_this), "__minLength", void 0);
285
+ _define_property(_assert_this_initialized(_this), "__maxLength", void 0);
286
+ _define_property(_assert_this_initialized(_this), "__regex", void 0);
287
+ _define_property(_assert_this_initialized(_this), "__endsWith", void 0);
288
+ _define_property(_assert_this_initialized(_this), "__startsWith", void 0);
289
+ _define_property(_assert_this_initialized(_this), "__includes", void 0);
290
+ return _this;
291
+ }
292
+ _create_class(StringSchema, [
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)('string', _this, adapter, adapter.string, function() {
307
+ return {
308
+ minLength: _this.__minLength,
309
+ maxLength: _this.__maxLength,
310
+ regex: _this.__regex,
311
+ endsWith: _this.__endsWith,
312
+ startsWith: _this.__startsWith,
313
+ includes: _this.__includes,
314
+ nullable: _this.__nullable,
315
+ optional: _this.__optional,
316
+ parsers: {
317
+ nullable: _this.__nullable.allow,
318
+ optional: _this.__optional.allow
319
+ }
320
+ };
321
+ }, {
322
+ maxLength: _string.maxLength,
323
+ minLength: _string.minLength,
324
+ endsWith: _string.endsWith,
325
+ startsWith: _string.startsWith,
326
+ regex: _string.regex,
327
+ includes: _string.includes
328
+ }, {
329
+ validatorsIfFallbackOrNotSupported: (0, _string.stringValidation)(),
330
+ shouldAddStringVersion: options.shouldAddStringVersion,
331
+ // eslint-disable-next-line ts/require-await
332
+ fallbackIfNotSupported: /*#__PURE__*/ _async_to_generator(function() {
333
+ return _ts_generator(this, function(_state) {
334
+ return [
335
+ 2,
336
+ []
337
+ ];
338
+ });
339
+ })
340
+ })
341
+ ];
342
+ });
343
+ });
344
+ return function(adapter) {
345
+ return _ref.apply(this, arguments);
346
+ };
347
+ }(), _this.__transformedSchemas, options, 'number')
348
+ ];
349
+ });
350
+ })();
351
+ }
352
+ },
353
+ {
354
+ /**
355
+ * 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.
356
+ *
357
+ * @example
358
+ * ```typescript
359
+ * import * as p from '@palmares/schemas';
360
+ *
361
+ * const numberSchema = p.number().refine((value) => {
362
+ * if (value < 0) return { code: 'invalid_number', message: 'The number should be greater than 0' };
363
+ * });
364
+ *
365
+ * const { errors, parsed } = await numberSchema.parse(-1);
366
+ *
367
+ * console.log(errors); // [{ isValid: false, code: 'invalid_number', message: 'The number should be greater than 0', path: [] }]
368
+ * ```
369
+ *
370
+ * @param refinementCallback - The callback that will be called to validate the value.
371
+ * @param options - Options for the refinement.
372
+ * @param options.isAsync - Whether the callback is async or not. Defaults to true.
373
+ */ key: "refine",
374
+ value: function refine(refinementCallback) {
375
+ return _get(_get_prototype_of(StringSchema.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(StringSchema.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(StringSchema.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(StringSchema.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(StringSchema.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(StringSchema.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(StringSchema.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(StringSchema.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(StringSchema.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
+ * ```typescript
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(StringSchema.prototype), "toValidate", this).call(this, toValidateCallback);
680
+ }
681
+ },
682
+ {
683
+ /**
684
+ * Defines a list of strings that are allowed, it's useful when you want to restrict the values that are allowed. Like a selector or a Choice field.
685
+ *
686
+ * @example
687
+ * ```typescript
688
+ * import * as p from '@palmares/schema';
689
+ *
690
+ * const schema = p.string().is(['Argentina', 'Brazil', 'Chile']);
691
+ *
692
+ * schema.parse('Argentina'); // { errors: [], parsed: 'Argentina' }
693
+ * schema.parse('Uruguay'); // { errors: [{ code: 'invalid_value', message: 'The value should be equal to Argentina, Brazil, Chile', path: [] }], parsed: 'Uruguay' }
694
+ * ```
695
+ *
696
+ * @param value - The list of numbers that are allowed
697
+ *
698
+ * @returns - The schema instance
699
+ */ key: "is",
700
+ value: function is(value) {
701
+ this.__is = {
702
+ value: value,
703
+ message: "The value should be equal to ".concat(value.join(', '))
704
+ };
705
+ return this;
706
+ }
707
+ },
708
+ {
709
+ /**
710
+ * Validates if the string ends with a specific value.
711
+ *
712
+ * @example
713
+ * ```typescript
714
+ * import * as p from '@palmares/schema';
715
+ *
716
+ * const schema = p.string().endsWith('.com');
717
+ *
718
+ * schema.parse('example.com'); // { errors: [], parsed: 'example.com' }
719
+ * schema.parse('example.org'); // { errors: [{ code: 'endsWith', message: 'The value should end with .com', path: [] }], parsed: 'example.org' }
720
+ * ```
721
+ *
722
+ * @param value - The value that the string should end with.
723
+ * @param options - The options for the endsWith function.
724
+ * @param options.message - The message to be shown when the value does not end with the value.
725
+ *
726
+ * @returns - The schema instance.
727
+ */ key: "endsWith",
728
+ value: function endsWith(value, options) {
729
+ this.__endsWith = {
730
+ value: value,
731
+ message: (options === null || options === void 0 ? void 0 : options.message) || "The value should end with ".concat(value)
732
+ };
733
+ return this;
734
+ }
735
+ },
736
+ {
737
+ /**
738
+ * Validates if the string starts with a specific value.
739
+ *
740
+ * @example
741
+ * ```typescript
742
+ * import * as p from '@palmares/schema';
743
+ *
744
+ * const schema = p.string().startsWith('https://');
745
+ *
746
+ * schema.parse('https://example.com'); // { errors: [], parsed: 'https://example.com' }
747
+ * schema.parse('http://example.com'); // { errors: [{ code: 'startsWith', message: 'The value should start with https://', path: [] }], parsed: 'http://example.com' }
748
+ * ```
749
+ *
750
+ * @param value - The value that the string should start with.
751
+ * @param options - The options for the startsWith function.
752
+ * @param options.message - The message to be shown when the value does not start with the value.
753
+ *
754
+ * @returns - The schema instance.
755
+ */ key: "startsWith",
756
+ value: function startsWith(value, options) {
757
+ this.__startsWith = {
758
+ value: value,
759
+ message: (options === null || options === void 0 ? void 0 : options.message) || "The value should start with ".concat(value)
760
+ };
761
+ return this;
762
+ }
763
+ },
764
+ {
765
+ /**
766
+ * Checks if the string includes a specific substring.
767
+ *
768
+ * @example
769
+ * ```typescript
770
+ * import * as p from '@palmares/schema';
771
+ *
772
+ * const schema = p.string().includes('for babies');
773
+ *
774
+ * schema.parse('Computer graphics for babies'); // { errors: [], parsed: 'Computer graphics for babies' }
775
+ * schema.parse('Learn javascript as you were 5'); // { errors: [{ code: 'includes', message: 'The string value should include the following substring 'for babies', path: [] }], parsed: 'example.org' }
776
+ * ```
777
+ *
778
+ * @param value - The value that the string should include.
779
+ * @param options - The options for the includes function.
780
+ * @param options.message - The message to be shown when the value does not include the value.
781
+ *
782
+ * @returns - The schema instance.
783
+ */ key: "includes",
784
+ value: function includes(value, options) {
785
+ this.__includes = {
786
+ value: value,
787
+ message: (options === null || options === void 0 ? void 0 : options.message) || "The string value should include the following substring '".concat(value, "'")
788
+ };
789
+ return this;
790
+ }
791
+ },
792
+ {
793
+ /**
794
+ * Validates if the string matches a specific regex.
795
+ *
796
+ * @example
797
+ * ```typescript
798
+ * import * as p from '@palmares/schema';
799
+ *
800
+ * const schema = p.string().regex(/^[a-z]+$/);
801
+ *
802
+ * schema.parse('abc'); // { errors: [], parsed: 'abc' }
803
+ * schema.parse('123'); // { errors: [{ code: 'regex', message: 'The value should match the following regex /^[a-z]+$/', path: [] }], parsed: '123' }
804
+ * ```
805
+ *
806
+ * @param value - The regex that the string should match.
807
+ * @param options - The options for the regex function.
808
+ * @param options.message - The message to be shown when the value does not match the regex.
809
+ *
810
+ * @returns - The schema instance.
811
+ */ key: "regex",
812
+ value: function regex(value, options) {
813
+ this.__regex = {
814
+ value: value,
815
+ message: (options === null || options === void 0 ? void 0 : options.message) || "The value should match the following regex '".concat(value.toString(), "'")
816
+ };
817
+ return this;
818
+ }
819
+ },
820
+ {
821
+ /**
822
+ * Validates if the string has a maximum length. Use { inclusive: true } to allow the value to have the same length as the maximum length.
823
+ *
824
+ * @example
825
+ * ```typescript
826
+ * import * as p from '@palmares/schema';
827
+ *
828
+ * const schema = p.string().maxLength(5);
829
+ *
830
+ * schema.parse('12345'); // { errors: [], parsed: '12345' }
831
+ * schema.parse('123456'); // { errors: [{ code: 'maxLength', message: 'The value should have a maximum length of 5', path: [] }], parsed: '123
832
+ * ```
833
+ *
834
+ * @param value - The maximum length that the string should have.
835
+ * @param options - The options for the maxLength function.
836
+ * @param options.message - The message to be shown when the value has a length greater than the maximum length.
837
+ * @param options.inclusive - Whether the value can have the same length as the maximum length. Defaults to false.
838
+ *
839
+ * @returns - The schema instance.
840
+ */ key: "maxLength",
841
+ value: function maxLength(value, options) {
842
+ this.__maxLength = {
843
+ value: value,
844
+ message: (options === null || options === void 0 ? void 0 : options.message) || "The value should have a maximum length of ".concat(value),
845
+ inclusive: typeof (options === null || options === void 0 ? void 0 : options.inclusive) === 'boolean' ? options.inclusive : false
846
+ };
847
+ return this;
848
+ }
849
+ },
850
+ {
851
+ /**
852
+ * Validates if the string has a minimum length. Use { inclusive: true } to allow the value to have the same length as the minimum length.
853
+ *
854
+ * @example
855
+ * ```typescript
856
+ * import * as p from '@palmares/schema';
857
+ *
858
+ * const schema = p.string().minLength(5);
859
+ *
860
+ * schema.parse('12345'); // { errors: [], parsed: '12345' }
861
+ * schema.parse('1234'); // { errors: [{ code: 'minLength', message: 'The value should have a minimum length of 5', path: [] }], parsed: '1234' }
862
+ * ```
863
+ *
864
+ * @param value - The minimum length that the string should have.
865
+ * @param options - The options for the minLength function.
866
+ * @param options.message - The message to be shown when the value has a length less than the minimum length.
867
+ * @param options.inclusive - Whether the value can have the same length as the minimum length. Defaults to false.
868
+ *
869
+ * @returns - The schema instance.
870
+ */ key: "minLength",
871
+ value: function minLength(value, options) {
872
+ this.__minLength = {
873
+ value: value,
874
+ message: (options === null || options === void 0 ? void 0 : options.message) || "The value should have a minimum length of ".concat(value),
875
+ inclusive: typeof (options === null || options === void 0 ? void 0 : options.inclusive) === 'boolean' ? options.inclusive : false
876
+ };
877
+ return this;
878
+ }
879
+ },
880
+ {
881
+ /**
882
+ * Validates if the string is a valid UUID.
883
+ *
884
+ * @example
885
+ * ```typescript
886
+ * import * as p from '@palmares/schema';
887
+ *
888
+ * const schema = p.string().uuid();
889
+ *
890
+ * schema.parse('550e8400-e29b-41d4-a716-446655440000'); // { errors: [], parsed: '550e8400-e29b-41d4-a716-446655440000' }
891
+ * ```
892
+ *
893
+ * @param options - The options for the uuid function.
894
+ * @param options.message - The message to be shown when the value is not a valid UUID. Defaults to 'The value should be a valid UUID'.
895
+ *
896
+ * @returns - The schema instance.
897
+ */ key: "uuid",
898
+ value: function uuid(options) {
899
+ this.__uuid = {
900
+ message: (options === null || options === void 0 ? void 0 : options.message) || 'The value should be a valid UUID'
901
+ };
902
+ return this;
903
+ }
904
+ },
905
+ {
906
+ /**
907
+ * Validates if the string is a valid email or not
908
+ *
909
+ * @example
910
+ * ```typescript
911
+ *
912
+ * import * as p from '@palmares/schema';
913
+ *
914
+ * const schema = p.string().email();
915
+ *
916
+ * schema.parse('john.doe@example.com'); // { errors: [], parsed: 'john.doe@example.com' }
917
+ * ```
918
+ *
919
+ * @param options - The options for the email function.
920
+ * @param options.message - The message to be shown when the value is not a valid email. Defaults to 'The value should be a valid email'.
921
+ *
922
+ * @returns - The schema instance.
923
+ */ key: "email",
924
+ value: function email(options) {
925
+ this.__email = {
926
+ message: (options === null || options === void 0 ? void 0 : options.message) || 'The value should be a valid email'
927
+ };
928
+ return this;
929
+ }
930
+ }
931
+ ], [
932
+ {
933
+ key: "new",
934
+ value: function _new() {
935
+ var returnValue = new StringSchema();
936
+ var adapterInstance = (0, _conf.getDefaultAdapter)();
937
+ returnValue.__transformedSchemas[adapterInstance.constructor.name] = {
938
+ transformed: false,
939
+ adapter: adapterInstance,
940
+ schemas: []
941
+ };
942
+ return returnValue;
943
+ }
944
+ }
945
+ ]);
946
+ return StringSchema;
947
+ }(_schema.default);
948
+ var string = StringSchema.new;