@availity/yup 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md ADDED
@@ -0,0 +1,433 @@
1
+ # Changelog
2
+
3
+ This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
4
+
5
+ # 1.0.0 (2023-08-23)
6
+
7
+
8
+ ### Bug Fixes
9
+
10
+ * add browser field for output ([0ce7170](https://github.com/Availity/sdk-js/commit/0ce717075a82675b8707e4db0cc07cd4af370f3d))
11
+ * **yup:** avDate fix for edge case invalid date length ([55f8b78](https://github.com/Availity/sdk-js/commit/55f8b781595a1f5aa610d63da53c4ffe3c7710e4))
12
+ * **yup:** avDate fix handles undefined correctly now ([85d25b7](https://github.com/Availity/sdk-js/commit/85d25b751b340273de8396abc310e5a27934376c))
13
+ * **yup:** avDate.typeError should not display for empty fields ([8bf47fb](https://github.com/Availity/sdk-js/commit/8bf47fb3a64f5b956b8ce0d4b27dbac46e08c864))
14
+ * **yup:** conditional logic fix ([3679957](https://github.com/Availity/sdk-js/commit/36799574f86674e1a41228c10bfba8d303958e02))
15
+ * **yup:** fix issue with exports not being found if yup and @availity/yup not imported in right order ([fa24f1d](https://github.com/Availity/sdk-js/commit/fa24f1d6f43bcf1371ca7b0613cacc2f3a0d3b01))
16
+ * **yup:** fixed bug in daterange causing to validate improperly ([5e90f3e](https://github.com/Availity/sdk-js/commit/5e90f3e8cd25c8aaebfbbf4b03868c3f1e77ecbe))
17
+ * **yup:** fixes duplicate name key preventing some validation tests for running, changes wording of validation messages ([ef144eb](https://github.com/Availity/sdk-js/commit/ef144eb972f821dc2c180ee74e7f9b5a0ae019bc))
18
+ * **yup:** fixes start date before end date logic ([6cc0ff7](https://github.com/Availity/sdk-js/commit/6cc0ff736358bc5aaf738a84d8abb258e85f57f4))
19
+ * **yup:** fixes type resolution bug where internal yup.date was no longer being overridden ([01ba375](https://github.com/Availity/sdk-js/commit/01ba3752455b98ebd701d5cfddeb4ab79af3c1a3))
20
+ * **yup:** fixes unhandled error for when value === undefined in avDate().between() validation ([d779f59](https://github.com/Availity/sdk-js/commit/d779f591cadeba3184faec13034e7b12a66d697a))
21
+ * **yup:** package change for major version update ([9ad040f](https://github.com/Availity/sdk-js/commit/9ad040ff7a4f7cbe7d5fdd37932d953287db805c)), closes [/github.com/jquense/yup/blob/375f1b9ed41f5043e123ea87a01a2dfe333c3927/CHANGELOG.md#0320-2020-12-03](https://github.com//github.com/jquense/yup/blob/375f1b9ed41f5043e123ea87a01a2dfe333c3927/CHANGELOG.md/issues/0320-2020-12-03)
22
+ * **yup:** refactor typeError, use _typeCheck ([24cea5e](https://github.com/Availity/sdk-js/commit/24cea5e2140d72ecec169dfde9fd94eb18956e66))
23
+
24
+
25
+ * build!: switch from lerna to nx and compile to esm with tsup ([c586085](https://github.com/Availity/sdk-js/commit/c5860856ca96b743a0653d335ea00f0889132f7f))
26
+
27
+
28
+ ### Features
29
+
30
+ * add npi method ([b1ac1a2](https://github.com/Availity/sdk-js/commit/b1ac1a258b32a74d7cce409304660a08089ddc46))
31
+ * **yup:** add phone validation schema ([98c3e29](https://github.com/Availity/sdk-js/commit/98c3e2968efe5f852872fda72839bda28dc7e38c))
32
+ * **yup:** add type definitions for phone schema ([319ca88](https://github.com/Availity/sdk-js/commit/319ca884a9fdd400c3983f751199263487dda8f6))
33
+ * **yup:** added yup validation library methods ([690f0c7](https://github.com/Availity/sdk-js/commit/690f0c7940748025a0d2c935fd4b8cbf81b29c28))
34
+ * **yup:** allow custom type error message for dateRange ([cc36cde](https://github.com/Availity/sdk-js/commit/cc36cde7d403f9787343fcecbf1d0fd9d8ac6bf7))
35
+ * **yup:** convert to ts and fix undefined class property ([f5a3a4f](https://github.com/Availity/sdk-js/commit/f5a3a4f944a0ae281e0eaabf3b6a38659a2acc71))
36
+ * **yup:** support inclusivity option ([94b1283](https://github.com/Availity/sdk-js/commit/94b1283c29e00f0db49ea58ae62d1cf16beef678))
37
+ * **yup:** switch to lodash from merge-options-es5 ([06456c9](https://github.com/Availity/sdk-js/commit/06456c90ac6ef7523c4ed0d2e4dc9af8c4a6dee5))
38
+ * **yup:** unit test for inclusivity ([25bf64b](https://github.com/Availity/sdk-js/commit/25bf64bd1fbd9b03ff609d8b8614ce40b7a4f4be))
39
+ * **yup:** update how accepted formats are handled for dates ([91006e5](https://github.com/Availity/sdk-js/commit/91006e564766e2bb66cdabc24dd2cdd69bc8b150))
40
+
41
+
42
+ ### BREAKING CHANGES
43
+
44
+ * Drop Internet Explorer support
45
+ * **yup:** the version of yup this package requires contains breaking changes from 0.32.0 onward
46
+ * **yup:** avDate and dateRange should now be imported directly from @availity/yup, eliminating the need for a 'magic' import from moment.js that depends on import order
47
+ * **yup:** Fixes TypeError: Cannot set property date of #<Object> by renaming 'date' and 'DateSchema' to 'avDa
48
+ te' and 'AvDateSchema'.
49
+
50
+
51
+
52
+ ## [5.1.2](https://github.com/Availity/sdk-js/compare/@availity/yup@5.1.1...@availity/yup@5.1.2) (2022-06-15)
53
+
54
+
55
+
56
+ ## [5.1.1](https://github.com/Availity/sdk-js/compare/@availity/yup@5.1.0...@availity/yup@5.1.1) (2022-05-24)
57
+
58
+
59
+
60
+ # [5.1.0](https://github.com/Availity/sdk-js/compare/@availity/yup@5.0.1...@availity/yup@5.1.0) (2022-05-20)
61
+
62
+
63
+ ### Features
64
+
65
+ * **yup:** update how accepted formats are handled for dates ([91006e5](https://github.com/Availity/sdk-js/commit/91006e564766e2bb66cdabc24dd2cdd69bc8b150))
66
+
67
+
68
+
69
+ ## [5.0.1](https://github.com/Availity/sdk-js/compare/@availity/yup@5.0.0...@availity/yup@5.0.1) (2022-04-28)
70
+
71
+
72
+ ### Bug Fixes
73
+
74
+ * add browser field for output ([0ce7170](https://github.com/Availity/sdk-js/commit/0ce717075a82675b8707e4db0cc07cd4af370f3d))
75
+
76
+
77
+
78
+ # [5.0.0](https://github.com/Availity/sdk-js/compare/@availity/yup@4.2.0...@availity/yup@5.0.0) (2022-04-28)
79
+
80
+
81
+ * build!: switch from lerna to nx and compile to esm with tsup ([c586085](https://github.com/Availity/sdk-js/commit/c5860856ca96b743a0653d335ea00f0889132f7f))
82
+
83
+
84
+ ### BREAKING CHANGES
85
+
86
+ * Drop Internet Explorer support
87
+
88
+
89
+
90
+ # 4.2.0 (2021-12-21)
91
+
92
+
93
+ ### Bug Fixes
94
+
95
+ * **yup:** conditional logic fix ([3679957](https://github.com/Availity/sdk-js/commit/36799574f86674e1a41228c10bfba8d303958e02))
96
+
97
+
98
+ ### Features
99
+
100
+ * **yup:** convert to ts and fix undefined class property ([f5a3a4f](https://github.com/Availity/sdk-js/commit/f5a3a4f944a0ae281e0eaabf3b6a38659a2acc71))
101
+
102
+
103
+
104
+
105
+
106
+ # 4.1.0 (2021-11-18)
107
+
108
+
109
+ ### Features
110
+
111
+ * **yup:** allow custom type error message for dateRange ([cc36cde](https://github.com/Availity/sdk-js/commit/cc36cde7d403f9787343fcecbf1d0fd9d8ac6bf7))
112
+
113
+
114
+
115
+
116
+
117
+ # 4.0.0 (2021-11-02)
118
+
119
+
120
+ ### Bug Fixes
121
+
122
+ * **yup:** package change for major version update ([9ad040f](https://github.com/Availity/sdk-js/commit/9ad040ff7a4f7cbe7d5fdd37932d953287db805c)), closes [/github.com/jquense/yup/blob/375f1b9ed41f5043e123ea87a01a2dfe333c3927/CHANGELOG.md#0320-2020-12-03](https://github.com//github.com/jquense/yup/blob/375f1b9ed41f5043e123ea87a01a2dfe333c3927/CHANGELOG.md/issues/0320-2020-12-03)
123
+
124
+
125
+ ### BREAKING CHANGES
126
+
127
+ * **yup:** the version of yup this package requires contains breaking changes from 0.32.0 onward
128
+
129
+
130
+
131
+
132
+
133
+ ## [3.2.1](https://github.com/Availity/sdk-js/compare/@availity/yup@3.2.0...@availity/yup@3.2.1) (2021-10-29)
134
+
135
+
136
+ ### Bug Fixes
137
+
138
+ * **yup:** fixes start date before end date logic ([6cc0ff7](https://github.com/Availity/sdk-js/commit/6cc0ff736358bc5aaf738a84d8abb258e85f57f4))
139
+
140
+
141
+
142
+
143
+
144
+ # 3.2.0 (2021-10-22)
145
+
146
+
147
+ ### Features
148
+
149
+ * **yup:** switch to lodash from merge-options-es5 ([06456c9](https://github.com/Availity/sdk-js/commit/06456c90ac6ef7523c4ed0d2e4dc9af8c4a6dee5))
150
+
151
+
152
+
153
+
154
+
155
+ ## [3.1.1](https://github.com/Availity/sdk-js/compare/@availity/yup@3.1.0...@availity/yup@3.1.1) (2021-06-16)
156
+
157
+
158
+ ### Bug Fixes
159
+
160
+ * **yup:** refactor typeError, use _typeCheck ([24cea5e](https://github.com/Availity/sdk-js/commit/24cea5e2140d72ecec169dfde9fd94eb18956e66))
161
+
162
+
163
+
164
+
165
+
166
+ # [3.1.0](https://github.com/Availity/sdk-js/compare/@availity/yup@3.0.11...@availity/yup@3.1.0) (2021-06-11)
167
+
168
+
169
+ ### Features
170
+
171
+ * **yup:** support inclusivity option ([94b1283](https://github.com/Availity/sdk-js/commit/94b1283c29e00f0db49ea58ae62d1cf16beef678))
172
+ * **yup:** unit test for inclusivity ([25bf64b](https://github.com/Availity/sdk-js/commit/25bf64bd1fbd9b03ff609d8b8614ce40b7a4f4be))
173
+
174
+
175
+
176
+
177
+
178
+ ## 3.0.11 (2021-05-25)
179
+
180
+ **Note:** Version bump only for package @availity/yup
181
+
182
+
183
+
184
+
185
+
186
+ ## [3.0.10](https://github.com/Availity/sdk-js/compare/@availity/yup@3.0.9...@availity/yup@3.0.10) (2021-05-17)
187
+
188
+ **Note:** Version bump only for package @availity/yup
189
+
190
+
191
+
192
+
193
+
194
+ ## 3.0.9 (2021-05-14)
195
+
196
+
197
+ ### Bug Fixes
198
+
199
+ * **yup:** avDate.typeError should not display for empty fields ([8bf47fb](https://github.com/Availity/sdk-js/commit/8bf47fb3a64f5b956b8ce0d4b27dbac46e08c864))
200
+
201
+
202
+
203
+
204
+
205
+ ## 3.0.8 (2020-10-06)
206
+
207
+
208
+ ### Bug Fixes
209
+
210
+ * **yup:** avDate fix for edge case invalid date length ([55f8b78](https://github.com/Availity/sdk-js/commit/55f8b781595a1f5aa610d63da53c4ffe3c7710e4))
211
+ * **yup:** avDate fix handles undefined correctly now ([85d25b7](https://github.com/Availity/sdk-js/commit/85d25b751b340273de8396abc310e5a27934376c))
212
+
213
+
214
+
215
+
216
+
217
+ ## 3.0.7 (2020-06-22)
218
+
219
+ **Note:** Version bump only for package @availity/yup
220
+
221
+
222
+
223
+
224
+
225
+ ## 3.0.6 (2020-05-01)
226
+
227
+ **Note:** Version bump only for package @availity/yup
228
+
229
+
230
+
231
+
232
+
233
+ ## 3.0.5 (2020-04-30)
234
+
235
+ **Note:** Version bump only for package @availity/yup
236
+
237
+
238
+
239
+
240
+
241
+ ## 3.0.4 (2020-04-22)
242
+
243
+ **Note:** Version bump only for package @availity/yup
244
+
245
+
246
+
247
+
248
+
249
+ ## 3.0.3 (2020-04-08)
250
+
251
+ **Note:** Version bump only for package @availity/yup
252
+
253
+
254
+
255
+
256
+
257
+ ## 3.0.2 (2020-04-06)
258
+
259
+ **Note:** Version bump only for package @availity/yup
260
+
261
+
262
+
263
+
264
+
265
+ ## 3.0.1 (2020-04-06)
266
+
267
+ **Note:** Version bump only for package @availity/yup
268
+
269
+
270
+
271
+
272
+
273
+ # [3.0.0](https://github.com/Availity/sdk-js/compare/@availity/yup@2.0.10...@availity/yup@3.0.0) (2020-04-06)
274
+
275
+
276
+ ### Bug Fixes
277
+
278
+ * **yup:** fix issue with exports not being found if yup and @availity/yup not imported in right order ([fa24f1d](https://github.com/Availity/sdk-js/commit/fa24f1d6f43bcf1371ca7b0613cacc2f3a0d3b01))
279
+
280
+
281
+ ### BREAKING CHANGES
282
+
283
+ * **yup:** avDate and dateRange should now be imported directly from @availity/yup, eliminating the need for a 'magic' import from moment.js that depends on import order
284
+
285
+
286
+
287
+
288
+
289
+ ## [2.0.10](https://github.com/Availity/sdk-js/compare/@availity/yup@2.0.9...@availity/yup@2.0.10) (2020-03-17)
290
+
291
+
292
+ ### Bug Fixes
293
+
294
+ * **yup:** fixes duplicate name key preventing some validation tests for running, changes wording of validation messages ([ef144eb](https://github.com/Availity/sdk-js/commit/ef144eb972f821dc2c180ee74e7f9b5a0ae019bc))
295
+ * **yup:** fixes unhandled error for when value === undefined in avDate().between() validation ([d779f59](https://github.com/Availity/sdk-js/commit/d779f591cadeba3184faec13034e7b12a66d697a))
296
+
297
+
298
+
299
+
300
+
301
+ ## [2.0.9](https://github.com/Availity/sdk-js/compare/@availity/yup@2.0.8...@availity/yup@2.0.9) (2020-02-28)
302
+
303
+ **Note:** Version bump only for package @availity/yup
304
+
305
+
306
+
307
+
308
+
309
+ ## [2.0.8](https://github.com/Availity/sdk-js/compare/@availity/yup@2.0.5...@availity/yup@2.0.8) (2020-02-13)
310
+
311
+ **Note:** Version bump only for package @availity/yup
312
+
313
+
314
+
315
+
316
+
317
+ ## [2.0.7](https://github.com/Availity/sdk-js/compare/@availity/yup@2.0.6...@availity/yup@2.0.7) (2020-02-13)
318
+
319
+ **Note:** Version bump only for package @availity/yup
320
+
321
+
322
+
323
+
324
+
325
+ ## [2.0.6](https://github.com/Availity/sdk-js/compare/@availity/yup@2.0.4...@availity/yup@2.0.6) (2020-02-13)
326
+
327
+ **Note:** Version bump only for package @availity/yup
328
+
329
+
330
+
331
+
332
+
333
+ ## [2.0.5](https://github.com/Availity/sdk-js/compare/@availity/yup@2.0.3...@availity/yup@2.0.5) (2020-02-13)
334
+
335
+ **Note:** Version bump only for package @availity/yup
336
+
337
+
338
+
339
+
340
+
341
+ ## [2.0.4](https://github.com/Availity/sdk-js/compare/@availity/yup@2.0.3...@availity/yup@2.0.4) (2020-02-13)
342
+
343
+ **Note:** Version bump only for package @availity/yup
344
+
345
+
346
+
347
+
348
+
349
+ ## [2.0.3](https://github.com/Availity/sdk-js/compare/@availity/yup@2.0.0...@availity/yup@2.0.3) (2020-02-13)
350
+
351
+ **Note:** Version bump only for package @availity/yup
352
+
353
+
354
+
355
+
356
+
357
+ ## [2.0.2](https://github.com/Availity/sdk-js/compare/@availity/yup@2.0.1...@availity/yup@2.0.2) (2020-02-13)
358
+
359
+ **Note:** Version bump only for package @availity/yup
360
+
361
+
362
+
363
+
364
+
365
+ ## [2.0.1](https://github.com/Availity/sdk-js/compare/@availity/yup@2.0.0...@availity/yup@2.0.1) (2020-02-13)
366
+
367
+ **Note:** Version bump only for package @availity/yup
368
+
369
+
370
+
371
+
372
+
373
+ # [2.0.0](https://github.com/Availity/sdk-js/compare/@availity/yup@1.3.4...@availity/yup@2.0.0) (2020-02-12)
374
+
375
+
376
+ ### Bug Fixes
377
+
378
+ * **yup:** fixes type resolution bug where internal yup.date was no longer being overridden ([01ba375](https://github.com/Availity/sdk-js/commit/01ba3752455b98ebd701d5cfddeb4ab79af3c1a3))
379
+
380
+
381
+ ### BREAKING CHANGES
382
+
383
+ * **yup:** Fixes TypeError: Cannot set property date of #<Object> by renaming 'date' and 'DateSchema' to 'avDa
384
+ te' and 'AvDateSchema'.
385
+
386
+
387
+
388
+
389
+
390
+ ## [1.3.4](https://github.com/Availity/sdk-js/compare/@availity/yup@1.3.3...@availity/yup@1.3.4) (2020-01-23)
391
+
392
+ **Note:** Version bump only for package @availity/yup
393
+
394
+
395
+
396
+
397
+
398
+ ## [1.3.3](https://github.com/Availity/sdk-js/compare/@availity/yup@1.3.2...@availity/yup@1.3.3) (2020-01-03)
399
+
400
+ **Note:** Version bump only for package @availity/yup
401
+
402
+ ## [1.3.2](https://github.com/Availity/sdk-js/compare/@availity/yup@1.3.1...@availity/yup@1.3.2) (2020-01-03)
403
+
404
+ **Note:** Version bump only for package @availity/yup
405
+
406
+ ## [1.3.1](https://github.com/Availity/sdk-js/compare/@availity/yup@1.3.0...@availity/yup@1.3.1) (2019-11-08)
407
+
408
+ **Note:** Version bump only for package @availity/yup
409
+
410
+ # [1.3.0](https://github.com/Availity/sdk-js/compare/@availity/yup@1.2.0...@availity/yup@1.3.0) (2019-09-13)
411
+
412
+ ### Features
413
+
414
+ - **yup:** add type definitions for phone schema ([319ca88](https://github.com/Availity/sdk-js/commit/319ca88))
415
+
416
+ # [1.2.0](https://github.com/Availity/sdk-js/compare/@availity/yup@1.1.1...@availity/yup@1.2.0) (2019-09-13)
417
+
418
+ ### Features
419
+
420
+ - **yup:** add phone validation schema ([98c3e29](https://github.com/Availity/sdk-js/commit/98c3e29))
421
+
422
+ ## [1.1.1](https://github.com/Availity/sdk-js/compare/@availity/yup@1.1.0...@availity/yup@1.1.1) (2019-08-19)
423
+
424
+ ### Bug Fixes
425
+
426
+ - **yup:** fixed bug in daterange causing to validate improperly ([5e90f3e](https://github.com/Availity/sdk-js/commit/5e90f3e))
427
+
428
+ # 1.1.0 (2019-08-12)
429
+
430
+ ### Features
431
+
432
+ - **yup:** added yup validation library methods ([690f0c7](https://github.com/Availity/sdk-js/commit/690f0c7))
433
+ - add npi method ([b1ac1a2](https://github.com/Availity/sdk-js/commit/b1ac1a2))
package/README.md ADDED
@@ -0,0 +1,27 @@
1
+ # @availity/yup
2
+
3
+ > Method extensions for [yup](https://github.com/jquense/yup)
4
+
5
+ [![Version](https://img.shields.io/npm/v/@availity/yup.svg?style=for-the-badge)](https://www.npmjs.com/package/@availity/yup)
6
+ [![NPM Downloads](https://img.shields.io/npm/dt/@availity/yup.svg?style=for-the-badge)](https://www.npmjs.com/package/@availity/yup)
7
+ [![Dependecy Status](https://img.shields.io/librariesio/release/npm/@availity/yup?style=for-the-badge)](https://github.com/Availity/sdk-js/blob/master/packages/yup/package.json)
8
+
9
+ ## Install
10
+
11
+ ### NPM
12
+
13
+ ```bash
14
+ npm install @availity/yup yup
15
+ ```
16
+
17
+ ### Yarn
18
+
19
+ ```bash
20
+ yarn add @availity/yup yup
21
+ ```
22
+
23
+ > You will need to also install [moment](https://www.npmjs.com/package/moment) if you plan on using the `date` or `dateRange` schemas
24
+
25
+ ## Documentation
26
+
27
+ Check out more documentation at [availity.github.io](https://availity.github.io/sdk-js/resources/yup)
@@ -0,0 +1,116 @@
1
+ import { Maybe, AnyObject, Optionals } from 'yup/lib/types';
2
+ import BaseSchema, { AnySchema } from 'yup/lib/schema';
3
+ import { TypeOf, Asserts } from 'yup/lib/util/types';
4
+ import { ObjectShape, TypeOfShape, AssertsShape } from 'yup/lib/object';
5
+ import Lazy from 'yup/lib/Lazy';
6
+ import { MixedSchema } from 'yup';
7
+ import moment, { Moment, unitOfTime } from 'moment';
8
+
9
+ declare class MomentDateSchema extends MixedSchema<Moment> {
10
+ _validFormats: string[];
11
+ constructor({ format, typeError }?: Options$1);
12
+ _typeCheck(value: unknown): value is Moment;
13
+ /**
14
+ * Validate if the date is on or after a specified min
15
+ */
16
+ min(min: string, message?: string): this;
17
+ /**
18
+ * Validate if the date is on or before a specified max
19
+ */
20
+ max(max: string, message?: string): this;
21
+ /**
22
+ * Validate if the date is between a specified min or max
23
+ *
24
+ * For Inlcusivity: `[]` === include & `()` === exclude
25
+ */
26
+ between(min: string, max: string, message?: string, inclusivity?: Inclusivity): this;
27
+ /**
28
+ * Set if the field is required and add a custom message
29
+ */
30
+ isRequired(isRequired?: boolean, message?: string): this;
31
+ }
32
+ type Inclusivity = '()' | '[)' | '(]' | '[]';
33
+ type Options$1 = {
34
+ format?: string | string[];
35
+ typeError?: string;
36
+ };
37
+ declare const avDate: (options?: Options$1) => MomentDateSchema;
38
+
39
+ declare class DateRangeSchema extends MixedSchema<DateRange> {
40
+ startKey: string;
41
+ endKey: string;
42
+ format: string;
43
+ constructor(options?: Options);
44
+ /**
45
+ * Convert the string to a moment object
46
+ */
47
+ getValidDate(value: string | Date | Moment): moment.Moment;
48
+ /**
49
+ * Validate based on min and max distance between dates
50
+ */
51
+ distance({ min: { value: minValue, units: minUnits, errorMessage: minErrorMessage }, max: { value: maxValue, units: maxUnits, errorMessage: maxErrorMessage }, }?: DistanceOptions): this;
52
+ /**
53
+ * Validate start date is after given min
54
+ */
55
+ min(min: string, message?: string): this;
56
+ /**
57
+ * Validate end date is before given max
58
+ */
59
+ max(max: string, message?: string): this;
60
+ /**
61
+ * Validate dates are between the set min and max
62
+ */
63
+ between(min: string, max: string, message?: string): this;
64
+ /**
65
+ * Set the field to be required or not
66
+ */
67
+ isRequired(isRequired?: boolean, msg?: string): this;
68
+ typeError({ message }: {
69
+ message: string;
70
+ }): this;
71
+ _typeCheck(range?: {
72
+ startDate?: Moment;
73
+ endDate?: Moment;
74
+ }): range is DateRange;
75
+ }
76
+ type Options = {
77
+ startKey?: string;
78
+ endKey?: string;
79
+ format?: string;
80
+ };
81
+ type DateRange = {
82
+ startDate?: Moment;
83
+ endDate?: Moment;
84
+ supportedFormats?: string[];
85
+ };
86
+ type DistanceValue = {
87
+ value: number;
88
+ units?: unitOfTime.DurationConstructor;
89
+ errorMessage?: string;
90
+ };
91
+ type DistanceOptions = {
92
+ min?: DistanceValue;
93
+ max?: DistanceValue;
94
+ };
95
+ declare const dateRange: (opts?: Options) => DateRangeSchema;
96
+
97
+ declare module 'yup' {
98
+ interface StringSchema<TType extends Maybe<string> = string | undefined, TContext extends AnyObject = AnyObject, TOut extends TType = TType> extends BaseSchema<TType, TContext, TOut> {
99
+ isRequired(required?: boolean, errorMessage?: string): StringSchema<TType, TContext>;
100
+ npi(errorMessage?: string): StringSchema<TType, TContext>;
101
+ phone(errorMessage?: string): StringSchema<TType, TContext>;
102
+ }
103
+ interface NumberSchema<TType extends Maybe<number> = number | undefined, TContext extends AnyObject = AnyObject, TOut extends TType = TType> extends BaseSchema<TType, TContext, TOut> {
104
+ isRequired(required?: boolean, errorMessage?: string): NumberSchema<TType, TContext, TOut>;
105
+ npi(errorMessage?: string): NumberSchema<TType, TContext, TOut>;
106
+ phone(errorMessage?: string): NumberSchema<TType, TContext, TOut>;
107
+ }
108
+ interface ArraySchema<T extends AnySchema | Lazy<any, any>, C extends AnyObject = AnyObject, TIn extends Maybe<TypeOf<T>[]> = TypeOf<T>[] | undefined, TOut extends Maybe<Asserts<T>[]> = Asserts<T>[] | Optionals<TIn>> extends BaseSchema<TIn, C, TOut> {
109
+ isRequired(required?: boolean, errorMessage?: string): ArraySchema<T, C, TIn, TOut>;
110
+ }
111
+ interface ObjectSchema<TShape extends ObjectShape, TContext extends AnyObject = AnyObject, TIn extends Maybe<TypeOfShape<TShape>> = TypeOfShape<TShape>, TOut extends Maybe<AssertsShape<TShape>> = AssertsShape<TShape> | Optionals<TIn>> extends BaseSchema<TIn, TContext, TOut> {
112
+ isRequired(required?: boolean, errorMessage?: string): ObjectSchema<TShape, TContext, TIn, TOut>;
113
+ }
114
+ }
115
+
116
+ export { avDate, dateRange };
@@ -0,0 +1,116 @@
1
+ import { Maybe, AnyObject, Optionals } from 'yup/lib/types';
2
+ import BaseSchema, { AnySchema } from 'yup/lib/schema';
3
+ import { TypeOf, Asserts } from 'yup/lib/util/types';
4
+ import { ObjectShape, TypeOfShape, AssertsShape } from 'yup/lib/object';
5
+ import Lazy from 'yup/lib/Lazy';
6
+ import { MixedSchema } from 'yup';
7
+ import moment, { Moment, unitOfTime } from 'moment';
8
+
9
+ declare class MomentDateSchema extends MixedSchema<Moment> {
10
+ _validFormats: string[];
11
+ constructor({ format, typeError }?: Options$1);
12
+ _typeCheck(value: unknown): value is Moment;
13
+ /**
14
+ * Validate if the date is on or after a specified min
15
+ */
16
+ min(min: string, message?: string): this;
17
+ /**
18
+ * Validate if the date is on or before a specified max
19
+ */
20
+ max(max: string, message?: string): this;
21
+ /**
22
+ * Validate if the date is between a specified min or max
23
+ *
24
+ * For Inlcusivity: `[]` === include & `()` === exclude
25
+ */
26
+ between(min: string, max: string, message?: string, inclusivity?: Inclusivity): this;
27
+ /**
28
+ * Set if the field is required and add a custom message
29
+ */
30
+ isRequired(isRequired?: boolean, message?: string): this;
31
+ }
32
+ type Inclusivity = '()' | '[)' | '(]' | '[]';
33
+ type Options$1 = {
34
+ format?: string | string[];
35
+ typeError?: string;
36
+ };
37
+ declare const avDate: (options?: Options$1) => MomentDateSchema;
38
+
39
+ declare class DateRangeSchema extends MixedSchema<DateRange> {
40
+ startKey: string;
41
+ endKey: string;
42
+ format: string;
43
+ constructor(options?: Options);
44
+ /**
45
+ * Convert the string to a moment object
46
+ */
47
+ getValidDate(value: string | Date | Moment): moment.Moment;
48
+ /**
49
+ * Validate based on min and max distance between dates
50
+ */
51
+ distance({ min: { value: minValue, units: minUnits, errorMessage: minErrorMessage }, max: { value: maxValue, units: maxUnits, errorMessage: maxErrorMessage }, }?: DistanceOptions): this;
52
+ /**
53
+ * Validate start date is after given min
54
+ */
55
+ min(min: string, message?: string): this;
56
+ /**
57
+ * Validate end date is before given max
58
+ */
59
+ max(max: string, message?: string): this;
60
+ /**
61
+ * Validate dates are between the set min and max
62
+ */
63
+ between(min: string, max: string, message?: string): this;
64
+ /**
65
+ * Set the field to be required or not
66
+ */
67
+ isRequired(isRequired?: boolean, msg?: string): this;
68
+ typeError({ message }: {
69
+ message: string;
70
+ }): this;
71
+ _typeCheck(range?: {
72
+ startDate?: Moment;
73
+ endDate?: Moment;
74
+ }): range is DateRange;
75
+ }
76
+ type Options = {
77
+ startKey?: string;
78
+ endKey?: string;
79
+ format?: string;
80
+ };
81
+ type DateRange = {
82
+ startDate?: Moment;
83
+ endDate?: Moment;
84
+ supportedFormats?: string[];
85
+ };
86
+ type DistanceValue = {
87
+ value: number;
88
+ units?: unitOfTime.DurationConstructor;
89
+ errorMessage?: string;
90
+ };
91
+ type DistanceOptions = {
92
+ min?: DistanceValue;
93
+ max?: DistanceValue;
94
+ };
95
+ declare const dateRange: (opts?: Options) => DateRangeSchema;
96
+
97
+ declare module 'yup' {
98
+ interface StringSchema<TType extends Maybe<string> = string | undefined, TContext extends AnyObject = AnyObject, TOut extends TType = TType> extends BaseSchema<TType, TContext, TOut> {
99
+ isRequired(required?: boolean, errorMessage?: string): StringSchema<TType, TContext>;
100
+ npi(errorMessage?: string): StringSchema<TType, TContext>;
101
+ phone(errorMessage?: string): StringSchema<TType, TContext>;
102
+ }
103
+ interface NumberSchema<TType extends Maybe<number> = number | undefined, TContext extends AnyObject = AnyObject, TOut extends TType = TType> extends BaseSchema<TType, TContext, TOut> {
104
+ isRequired(required?: boolean, errorMessage?: string): NumberSchema<TType, TContext, TOut>;
105
+ npi(errorMessage?: string): NumberSchema<TType, TContext, TOut>;
106
+ phone(errorMessage?: string): NumberSchema<TType, TContext, TOut>;
107
+ }
108
+ interface ArraySchema<T extends AnySchema | Lazy<any, any>, C extends AnyObject = AnyObject, TIn extends Maybe<TypeOf<T>[]> = TypeOf<T>[] | undefined, TOut extends Maybe<Asserts<T>[]> = Asserts<T>[] | Optionals<TIn>> extends BaseSchema<TIn, C, TOut> {
109
+ isRequired(required?: boolean, errorMessage?: string): ArraySchema<T, C, TIn, TOut>;
110
+ }
111
+ interface ObjectSchema<TShape extends ObjectShape, TContext extends AnyObject = AnyObject, TIn extends Maybe<TypeOfShape<TShape>> = TypeOfShape<TShape>, TOut extends Maybe<AssertsShape<TShape>> = AssertsShape<TShape> | Optionals<TIn>> extends BaseSchema<TIn, TContext, TOut> {
112
+ isRequired(required?: boolean, errorMessage?: string): ObjectSchema<TShape, TContext, TIn, TOut>;
113
+ }
114
+ }
115
+
116
+ export { avDate, dateRange };