@availity/yup 5.1.6 → 6.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 CHANGED
@@ -2,6 +2,24 @@
2
2
 
3
3
  This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
4
4
 
5
+ # [6.0.0](https://github.com/Availity/sdk-js/compare/@availity/yup@5.1.7...@availity/yup@6.0.0) (2024-07-29)
6
+
7
+
8
+ ### chore
9
+
10
+ * **yup:** upgrade to node 18 and 20 ([007868b](https://github.com/Availity/sdk-js/commit/007868b84070a36ea6295904825816dfb82cdf60))
11
+
12
+
13
+ ### BREAKING CHANGES
14
+
15
+ * **yup:** drop support for node 14 and 16
16
+
17
+
18
+
19
+ ## [5.1.7](https://github.com/Availity/sdk-js/compare/@availity/yup@5.1.6...@availity/yup@5.1.7) (2024-07-29)
20
+
21
+
22
+
5
23
  ## [5.1.6](https://github.com/Availity/sdk-js/compare/@availity/yup@5.1.5...@availity/yup@5.1.6) (2024-05-30)
6
24
 
7
25
 
package/dist/index.js CHANGED
@@ -36,6 +36,86 @@ __export(src_exports, {
36
36
  module.exports = __toCommonJS(src_exports);
37
37
  var import_yup3 = require("yup");
38
38
 
39
+ // src/isRequired.ts
40
+ function isRequired(isRequired2 = true, msg) {
41
+ return this.test({
42
+ name: "isRequired",
43
+ exclusive: true,
44
+ message: msg || "This field is required.",
45
+ test(value) {
46
+ if (isRequired2) {
47
+ if (this.schema.type === "array") {
48
+ return Array.isArray(value) ? value.length > 0 : value !== void 0;
49
+ }
50
+ if (this.schema.type === "string") {
51
+ return value !== void 0 && value !== "";
52
+ }
53
+ return value !== void 0;
54
+ }
55
+ return true;
56
+ }
57
+ });
58
+ }
59
+ var isRequired_default = isRequired;
60
+
61
+ // src/npi.ts
62
+ var INTEGER_REGEX = /^\d*$/;
63
+ function npi(msg) {
64
+ return this.test({
65
+ name: "npi",
66
+ exclusive: true,
67
+ message: msg || "This field is invalid.",
68
+ test(value) {
69
+ if (!value)
70
+ return true;
71
+ value += "";
72
+ if (!INTEGER_REGEX.test(value) || value.length !== 10) {
73
+ return false;
74
+ }
75
+ const firstDigit = value.charAt(0);
76
+ if (["1", "2", "3", "4"].indexOf(firstDigit) < 0) {
77
+ return false;
78
+ }
79
+ const digit = Number.parseInt(value.charAt(9), 10);
80
+ value = value.substring(0, 9);
81
+ value = `80840${value}`;
82
+ let alternate = true;
83
+ let total = 0;
84
+ for (let i = value.length; i > 0; i--) {
85
+ let next = Number.parseInt(value.charAt(i - 1), 10);
86
+ if (alternate) {
87
+ next *= 2;
88
+ if (next > 9) {
89
+ next = next % 10 + 1;
90
+ }
91
+ }
92
+ total += next;
93
+ alternate = !alternate;
94
+ }
95
+ const roundUp = Math.ceil(total / 10) * 10;
96
+ const calculatedCheck = roundUp - total;
97
+ return calculatedCheck === digit;
98
+ }
99
+ });
100
+ }
101
+ var npi_default = npi;
102
+
103
+ // src/phone.ts
104
+ var NANP_REGEXP = /^(\+?1[\s.-]?)?\(?[2-9]\d{2}[\s).-]?\s?[2-9]\d{2}[\s.-]?\d{4}$/;
105
+ function phone(msg) {
106
+ return this.test({
107
+ name: "phone",
108
+ exclusive: true,
109
+ message: msg || "This field is invalid",
110
+ test(value) {
111
+ if (!value)
112
+ return true;
113
+ return NANP_REGEXP.test(value);
114
+ }
115
+ });
116
+ }
117
+ var phone_default = phone;
118
+
39
119
  // src/date.ts
40
120
  var import_yup = require("yup");
41
121
  var import_moment = __toESM(require("moment"));
@@ -297,86 +377,6 @@ var DateRangeSchema = class extends import_yup2.MixedSchema {
297
377
  };
298
378
  var dateRange = (opts) => new DateRangeSchema(opts);
299
379
 
300
- // src/isRequired.ts
301
- function isRequired(isRequired2 = true, msg) {
302
- return this.test({
303
- name: "isRequired",
304
- exclusive: true,
305
- message: msg || "This field is required.",
306
- test(value) {
307
- if (isRequired2) {
308
- if (this.schema.type === "array") {
309
- return Array.isArray(value) ? value.length > 0 : value !== void 0;
310
- }
311
- if (this.schema.type === "string") {
312
- return value !== void 0 && value !== "";
313
- }
314
- return value !== void 0;
315
- }
316
- return true;
317
- }
318
- });
319
- }
320
- var isRequired_default = isRequired;
321
-
322
- // src/npi.ts
323
- var INTEGER_REGEX = /^\d*$/;
324
- function npi(msg) {
325
- return this.test({
326
- name: "npi",
327
- exclusive: true,
328
- message: msg || "This field is invalid.",
329
- test(value) {
330
- if (!value)
331
- return true;
332
- value += "";
333
- if (!INTEGER_REGEX.test(value) || value.length !== 10) {
334
- return false;
335
- }
336
- const firstDigit = value.charAt(0);
337
- if (["1", "2", "3", "4"].indexOf(firstDigit) < 0) {
338
- return false;
339
- }
340
- const digit = Number.parseInt(value.charAt(9), 10);
341
- value = value.substring(0, 9);
342
- value = `80840${value}`;
343
- let alternate = true;
344
- let total = 0;
345
- for (let i = value.length; i > 0; i--) {
346
- let next = Number.parseInt(value.charAt(i - 1), 10);
347
- if (alternate) {
348
- next *= 2;
349
- if (next > 9) {
350
- next = next % 10 + 1;
351
- }
352
- }
353
- total += next;
354
- alternate = !alternate;
355
- }
356
- const roundUp = Math.ceil(total / 10) * 10;
357
- const calculatedCheck = roundUp - total;
358
- return calculatedCheck === digit;
359
- }
360
- });
361
- }
362
- var npi_default = npi;
363
-
364
- // src/phone.ts
365
- var NANP_REGEXP = /^(\+?1[\s.-]?)?\(?[2-9]\d{2}[\s).-]?\s?[2-9]\d{2}[\s.-]?\d{4}$/;
366
- function phone(msg) {
367
- return this.test({
368
- name: "phone",
369
- exclusive: true,
370
- message: msg || "This field is invalid",
371
- test(value) {
372
- if (!value)
373
- return true;
374
- return NANP_REGEXP.test(value);
375
- }
376
- });
377
- }
378
- var phone_default = phone;
379
-
380
380
  // src/index.ts
381
381
  (0, import_yup3.addMethod)(import_yup3.array, "isRequired", isRequired_default);
382
382
  (0, import_yup3.addMethod)(import_yup3.number, "isRequired", isRequired_default);
package/dist/index.mjs CHANGED
@@ -1,6 +1,86 @@
1
1
  // src/index.ts
2
2
  import { addMethod, array, number, object, string } from "yup";
3
3
 
4
+ // src/isRequired.ts
5
+ function isRequired(isRequired2 = true, msg) {
6
+ return this.test({
7
+ name: "isRequired",
8
+ exclusive: true,
9
+ message: msg || "This field is required.",
10
+ test(value) {
11
+ if (isRequired2) {
12
+ if (this.schema.type === "array") {
13
+ return Array.isArray(value) ? value.length > 0 : value !== void 0;
14
+ }
15
+ if (this.schema.type === "string") {
16
+ return value !== void 0 && value !== "";
17
+ }
18
+ return value !== void 0;
19
+ }
20
+ return true;
21
+ }
22
+ });
23
+ }
24
+ var isRequired_default = isRequired;
25
+
26
+ // src/npi.ts
27
+ var INTEGER_REGEX = /^\d*$/;
28
+ function npi(msg) {
29
+ return this.test({
30
+ name: "npi",
31
+ exclusive: true,
32
+ message: msg || "This field is invalid.",
33
+ test(value) {
34
+ if (!value)
35
+ return true;
36
+ value += "";
37
+ if (!INTEGER_REGEX.test(value) || value.length !== 10) {
38
+ return false;
39
+ }
40
+ const firstDigit = value.charAt(0);
41
+ if (["1", "2", "3", "4"].indexOf(firstDigit) < 0) {
42
+ return false;
43
+ }
44
+ const digit = Number.parseInt(value.charAt(9), 10);
45
+ value = value.substring(0, 9);
46
+ value = `80840${value}`;
47
+ let alternate = true;
48
+ let total = 0;
49
+ for (let i = value.length; i > 0; i--) {
50
+ let next = Number.parseInt(value.charAt(i - 1), 10);
51
+ if (alternate) {
52
+ next *= 2;
53
+ if (next > 9) {
54
+ next = next % 10 + 1;
55
+ }
56
+ }
57
+ total += next;
58
+ alternate = !alternate;
59
+ }
60
+ const roundUp = Math.ceil(total / 10) * 10;
61
+ const calculatedCheck = roundUp - total;
62
+ return calculatedCheck === digit;
63
+ }
64
+ });
65
+ }
66
+ var npi_default = npi;
67
+
68
+ // src/phone.ts
69
+ var NANP_REGEXP = /^(\+?1[\s.-]?)?\(?[2-9]\d{2}[\s).-]?\s?[2-9]\d{2}[\s.-]?\d{4}$/;
70
+ function phone(msg) {
71
+ return this.test({
72
+ name: "phone",
73
+ exclusive: true,
74
+ message: msg || "This field is invalid",
75
+ test(value) {
76
+ if (!value)
77
+ return true;
78
+ return NANP_REGEXP.test(value);
79
+ }
80
+ });
81
+ }
82
+ var phone_default = phone;
83
+
4
84
  // src/date.ts
5
85
  import { MixedSchema } from "yup";
6
86
  import moment from "moment";
@@ -262,86 +342,6 @@ var DateRangeSchema = class extends MixedSchema2 {
262
342
  };
263
343
  var dateRange = (opts) => new DateRangeSchema(opts);
264
344
 
265
- // src/isRequired.ts
266
- function isRequired(isRequired2 = true, msg) {
267
- return this.test({
268
- name: "isRequired",
269
- exclusive: true,
270
- message: msg || "This field is required.",
271
- test(value) {
272
- if (isRequired2) {
273
- if (this.schema.type === "array") {
274
- return Array.isArray(value) ? value.length > 0 : value !== void 0;
275
- }
276
- if (this.schema.type === "string") {
277
- return value !== void 0 && value !== "";
278
- }
279
- return value !== void 0;
280
- }
281
- return true;
282
- }
283
- });
284
- }
285
- var isRequired_default = isRequired;
286
-
287
- // src/npi.ts
288
- var INTEGER_REGEX = /^\d*$/;
289
- function npi(msg) {
290
- return this.test({
291
- name: "npi",
292
- exclusive: true,
293
- message: msg || "This field is invalid.",
294
- test(value) {
295
- if (!value)
296
- return true;
297
- value += "";
298
- if (!INTEGER_REGEX.test(value) || value.length !== 10) {
299
- return false;
300
- }
301
- const firstDigit = value.charAt(0);
302
- if (["1", "2", "3", "4"].indexOf(firstDigit) < 0) {
303
- return false;
304
- }
305
- const digit = Number.parseInt(value.charAt(9), 10);
306
- value = value.substring(0, 9);
307
- value = `80840${value}`;
308
- let alternate = true;
309
- let total = 0;
310
- for (let i = value.length; i > 0; i--) {
311
- let next = Number.parseInt(value.charAt(i - 1), 10);
312
- if (alternate) {
313
- next *= 2;
314
- if (next > 9) {
315
- next = next % 10 + 1;
316
- }
317
- }
318
- total += next;
319
- alternate = !alternate;
320
- }
321
- const roundUp = Math.ceil(total / 10) * 10;
322
- const calculatedCheck = roundUp - total;
323
- return calculatedCheck === digit;
324
- }
325
- });
326
- }
327
- var npi_default = npi;
328
-
329
- // src/phone.ts
330
- var NANP_REGEXP = /^(\+?1[\s.-]?)?\(?[2-9]\d{2}[\s).-]?\s?[2-9]\d{2}[\s.-]?\d{4}$/;
331
- function phone(msg) {
332
- return this.test({
333
- name: "phone",
334
- exclusive: true,
335
- message: msg || "This field is invalid",
336
- test(value) {
337
- if (!value)
338
- return true;
339
- return NANP_REGEXP.test(value);
340
- }
341
- });
342
- }
343
- var phone_default = phone;
344
-
345
345
  // src/index.ts
346
346
  addMethod(array, "isRequired", isRequired_default);
347
347
  addMethod(number, "isRequired", isRequired_default);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@availity/yup",
3
- "version": "5.1.6",
3
+ "version": "6.0.0",
4
4
  "description": "Additional methods for yup validation library",
5
5
  "keywords": [
6
6
  "yup",
@@ -22,6 +22,9 @@
22
22
  "main": "./dist/index.js",
23
23
  "module": "./dist/index.mjs",
24
24
  "types": "./dist/index.d.ts",
25
+ "engines": {
26
+ "node": "^18.0.0 || ^20.0.0"
27
+ },
25
28
  "scripts": {
26
29
  "build": "tsup src/index.ts --format esm,cjs --dts",
27
30
  "dev": "tsup src/index.ts --format esm,cjs --watch --dts",
@@ -37,7 +40,7 @@
37
40
  "devDependencies": {
38
41
  "moment": "^2.30.1",
39
42
  "tsup": "^7.2.0",
40
- "typescript": "^5.1.6"
43
+ "typescript": "^5.5.4"
41
44
  },
42
45
  "peerDependencies": {
43
46
  "moment": "^2.24.0"
package/project.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
- "root": "packages/yup",
2
+ "name": "@availity/yup",
3
+ "$schema": "../../node_modules/nx/schemas/project-schema.json",
3
4
  "projectType": "library",
4
5
  "targets": {
5
6
  "test": {
6
7
  "executor": "@nx/jest:jest",
7
- "outputs": ["coverage/yup"],
8
+ "outputs": ["{workspaceRoot}/coverage/yup"],
8
9
  "options": {
9
- "jestConfig": "packages/yup/jest.config.js",
10
- "passWithNoTests": true
10
+ "jestConfig": "packages/yup/jest.config.js"
11
11
  }
12
12
  },
13
13
  "version": {
@@ -15,16 +15,15 @@
15
15
  "options": {
16
16
  "preset": "angular",
17
17
  "commitMessageFormat": "chore({projectName}): release version ${version} [skip ci]",
18
- "tagPrefix": "@availity/{projectName}@",
18
+ "tagPrefix": "{projectName}@",
19
19
  "baseBranch": "master",
20
20
  "trackDeps": true
21
21
  }
22
22
  },
23
23
  "lint": {
24
- "executor": "@nx/linter:eslint",
24
+ "executor": "@nx/eslint:lint",
25
25
  "options": {
26
26
  "eslintConfig": ".eslintrc.yaml",
27
- "lintFilePatterns": ["packages/yup/**/*.{js,ts}"],
28
27
  "silent": false,
29
28
  "fix": false,
30
29
  "cache": true,
package/src/index.ts CHANGED
@@ -5,13 +5,12 @@ import { Asserts, TypeOf } from 'yup/lib/util/types';
5
5
  import { AssertsShape, ObjectShape, TypeOfShape } from 'yup/lib/object';
6
6
  import Lazy from 'yup/lib/Lazy';
7
7
 
8
- import { avDate } from './date';
9
- import { dateRange } from './dateRange';
10
8
  import isRequired from './isRequired';
11
9
  import npi from './npi';
12
10
  import phone from './phone';
13
11
 
14
- export { avDate, dateRange };
12
+ export { avDate } from './date';
13
+ export { dateRange } from './dateRange';
15
14
 
16
15
  addMethod(array, 'isRequired', isRequired);
17
16
  addMethod(number, 'isRequired', isRequired);