@jdlien/validator-utils 2.0.0 → 2.2.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/LICENSE +7 -0
- package/README.md +129 -3
- package/dist/index.d.ts +1 -0
- package/dist/{validator-utils.d.ts → src/validator-utils.d.ts} +19 -0
- package/dist/validator-utils.cjs +1 -0
- package/dist/validator-utils.js +1 -1
- package/dist/validator-utils.mjs +440 -0
- package/package.json +26 -20
package/LICENSE
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
ISC License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 JD Lien
|
|
4
|
+
|
|
5
|
+
Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
|
|
6
|
+
|
|
7
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
## Introduction
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
The Validator Utils package is a lightweight (~15KB or ~5KB gzipped) library of utility functions that can validate and sanitize
|
|
6
6
|
dates, times, strings, numbers, and more. This is especially useful in forms. This package is the sole dependency for the [@jdlien/validator package](https://github.com/jdlien/validator).
|
|
7
7
|
|
|
8
8
|
This package was separated from Validator so that it could be used in other projects without
|
|
@@ -12,12 +12,32 @@ pulling in the entire Validator package if you only need some of its validation
|
|
|
12
12
|
|
|
13
13
|
```bash
|
|
14
14
|
npm install @jdlien/validator-utils
|
|
15
|
+
|
|
16
|
+
# or
|
|
17
|
+
|
|
18
|
+
yarn add @jdlien/validator-utils
|
|
19
|
+
|
|
20
|
+
# or
|
|
21
|
+
|
|
22
|
+
pnpm add @jdlien/validator-utils
|
|
15
23
|
```
|
|
16
24
|
|
|
17
25
|
## Utility Functions
|
|
18
26
|
|
|
19
27
|
Validator includes several utility functions that may be useful in your own code, so they are exported as part of the module.
|
|
20
|
-
If you
|
|
28
|
+
If you're using a bundler:
|
|
29
|
+
|
|
30
|
+
```javascript
|
|
31
|
+
import { parseDate, formatDateTime } from '@jdlien/validator-utils'
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
If you're using CommonJS:
|
|
35
|
+
|
|
36
|
+
```javascript
|
|
37
|
+
const { parseDate, formatDateTime } = require('@jdlien/validator-utils')
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
If you prefer to access the utilities as a single object:
|
|
21
41
|
|
|
22
42
|
```javascript
|
|
23
43
|
import * as validatorUtils from '@jdlien/validator-utils'
|
|
@@ -25,6 +45,21 @@ import * as validatorUtils from '@jdlien/validator-utils'
|
|
|
25
45
|
const { parseDate, formatDateTime } = validatorUtils
|
|
26
46
|
```
|
|
27
47
|
|
|
48
|
+
If you are not using a bundler, you can load a UMD or ESM build directly:
|
|
49
|
+
|
|
50
|
+
```html
|
|
51
|
+
<!-- UMD (global validatorUtils) -->
|
|
52
|
+
<script src="https://unpkg.com/@jdlien/validator-utils/dist/validator-utils.js"></script>
|
|
53
|
+
<script>
|
|
54
|
+
const { parseDate, formatDateTime } = validatorUtils
|
|
55
|
+
</script>
|
|
56
|
+
|
|
57
|
+
<!-- ESM (module) -->
|
|
58
|
+
<script type="module">
|
|
59
|
+
import { parseDate, formatDateTime } from 'https://unpkg.com/@jdlien/validator-utils/dist/validator-utils.mjs'
|
|
60
|
+
</script>
|
|
61
|
+
```
|
|
62
|
+
|
|
28
63
|
Here is a list of the utility functions:
|
|
29
64
|
|
|
30
65
|
- **isFormControl**: Determines if an element is an HTML input, select, or textarea element.
|
|
@@ -38,7 +73,8 @@ Here is a list of the utility functions:
|
|
|
38
73
|
- **formatDateTime**: Formats a date string or Date object into a string with a specified format.
|
|
39
74
|
- **parseDateToString**: Parses a date string or Date object into a formatted string with the specified moment.js-style date format.
|
|
40
75
|
- **isDate**: Determines if a value is a valid date.
|
|
41
|
-
- **isDateInRange**: Determines if a date falls within a specified range (
|
|
76
|
+
- **isDateInRange**: Determines if a date falls within a specified range. Supports keywords (`past`, `future`, `today`), specific date ranges (`2023-01-01:2023-12-31`), open-ended ranges (`:2025-12-31`, `2020-01-01:`), relative offsets (`-30d:+30d`, `-1y:`, `:+6m`), and date-time bounds (`2024-01-01T12:00:2024-01-01T14:00`).
|
|
77
|
+
- **parseRelativeDate**: Parses a relative date offset (e.g., `-30d`, `+2w`, `30d`, `-6m`, `+1y`) into a Date object.
|
|
42
78
|
- **isTime**: Determines if a value is a valid time.
|
|
43
79
|
- **isEmail**: Determines if a value is a valid email address.
|
|
44
80
|
- **parseNANPTel**: Parses a North American phone number string into a standardized format.
|
|
@@ -46,6 +82,8 @@ Here is a list of the utility functions:
|
|
|
46
82
|
- **parseInteger**: Parses an integer string into a standardized format.
|
|
47
83
|
- **isNumber**: Determines if a value is a valid number.
|
|
48
84
|
- **parseNumber**: Parses a number string into a standardized format.
|
|
85
|
+
- **parseBytes**: Parses a human-readable byte size (e.g., "1.5 MB", "2GiB") into bytes.
|
|
86
|
+
- **formatBytes**: Formats a byte count as a human-readable string (e.g., "1.5 MB", "512 B").
|
|
49
87
|
- **isInteger**: Determines if a value is a valid integer.
|
|
50
88
|
- **parseUrl**: Parses a URL string into a standardized format.
|
|
51
89
|
- **isUrl**: Determines if a value is a valid URL.
|
|
@@ -64,3 +102,91 @@ Install dev dependencies:
|
|
|
64
102
|
```bash
|
|
65
103
|
pnpm install
|
|
66
104
|
```
|
|
105
|
+
|
|
106
|
+
Run tests with coverage (100% required for release):
|
|
107
|
+
|
|
108
|
+
```bash
|
|
109
|
+
pnpm coverage
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
Build the project for testing/release:
|
|
113
|
+
|
|
114
|
+
```bash
|
|
115
|
+
pnpm build
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
### Release Checklist
|
|
119
|
+
|
|
120
|
+
1. Ensure 100% test coverage: `pnpm coverage`
|
|
121
|
+
2. Check bundle size hasn't grown unexpectedly: `pnpm size:wire`
|
|
122
|
+
3. Update version in `package.json` with correct semantic versioning
|
|
123
|
+
4. Update `CHANGELOG.md` with details of all changes
|
|
124
|
+
5. Update `README.md` to ensure documentation is current
|
|
125
|
+
6. Verify new functions are exported from `index.ts`
|
|
126
|
+
7. Run `pnpm build` and ensure it completes with no errors
|
|
127
|
+
8. Commit and push all changes to git
|
|
128
|
+
9. Tag the release to match `package.json` version: `git tag v2.x.x && git push --tags`
|
|
129
|
+
10. Publish to npm: `pnpm publish` (may require `npm login` first)
|
|
130
|
+
11. Update live demo at https://jdlien.com/validator/: pull, `pnpm update` and `pnpm build` on server
|
|
131
|
+
|
|
132
|
+
## FAQ
|
|
133
|
+
|
|
134
|
+
### What date formats does `parseDate` accept?
|
|
135
|
+
|
|
136
|
+
Very flexible. It handles ISO 8601 (`2024-01-15`), US (`01/15/2024`, `1-15-24`), European (`15.01.2024`), named months (`Jan 15, 2024`, `15 January 2024`), compact (`20240115`, `240115`), relative keywords (`today`, `tomorrow`, `yesterday`), and two-digit years (interpreted within 20 years of current date). Day names are ignored. The parser intelligently determines what format dates are in based on heuristics, so even more formats than this are supported. For the most part, if it looks like a date used in the western world, it's supported.
|
|
137
|
+
|
|
138
|
+
### Does it handle timezones?
|
|
139
|
+
|
|
140
|
+
No. All dates are parsed and returned in local time. If you pass an ISO string with a timezone offset, the timezone is ignored and the literal date/time values are used.
|
|
141
|
+
|
|
142
|
+
### Does it support non-English date formats?
|
|
143
|
+
|
|
144
|
+
Yes. It fully supports Chinese (`2024年1月15日`), Japanese, and Korean (`2024년 1월 15일`) date formats. It also recognizes common French (`février`, `avril`, `mai`, `juin`, `juillet`, `août`) and Spanish (`enero`, `abril`, `agosto`) month prefixes, and falls back to the browser's `Date` parser for additional locales.
|
|
145
|
+
|
|
146
|
+
### Why does `parseDate` return an Invalid Date?
|
|
147
|
+
|
|
148
|
+
Common causes: unrecognized format, ambiguous input the parser can't resolve, or genuinely invalid dates. Try a more explicit format like `YYYY-MM-DD`. Use `isDate()` to check validity before using the result.
|
|
149
|
+
|
|
150
|
+
### Can I tree-shake to only include functions I use?
|
|
151
|
+
|
|
152
|
+
Yes. The package has `"sideEffects": false` in package.json, so bundlers can eliminate unused exports. Use named imports (`import { parseDate } from '...'`) for best results.
|
|
153
|
+
|
|
154
|
+
### Why is the ESM build larger than CJS?
|
|
155
|
+
|
|
156
|
+
The ESM build (~15KB) preserves newlines for debuggability; CJS/UMD (~12KB) are fully minified. The gzipped sizes are nearly identical (~4.7-5.2KB) since whitespace compresses well.
|
|
157
|
+
|
|
158
|
+
### Does it work in Node.js?
|
|
159
|
+
|
|
160
|
+
Mostly. Two functions require a browser environment:
|
|
161
|
+
- `isColor()` uses `CSS.supports()` — returns `false` in Node for non-trivial colors
|
|
162
|
+
- `parseColor()` uses a canvas element — will throw in Node without a canvas polyfill
|
|
163
|
+
|
|
164
|
+
All other functions work in Node.js.
|
|
165
|
+
|
|
166
|
+
### What browsers are supported?
|
|
167
|
+
|
|
168
|
+
Modern browsers (ES2020+). No IE11 support. The UMD build works in any browser that supports ES6.
|
|
169
|
+
|
|
170
|
+
### When should I use this vs `@jdlien/validator`?
|
|
171
|
+
|
|
172
|
+
Use **validator-utils** when you only need parsing/validation functions (e.g., `parseDate`, `isEmail`). Use **@jdlien/validator** when you need form validation with error messages, DOM integration, and field-level validation rules.
|
|
173
|
+
|
|
174
|
+
### Why use this instead of date-fns, dayjs, or moment.js?
|
|
175
|
+
|
|
176
|
+
Size and focus. This library is ~5KB gzipped vs 20-70KB+ for full date libraries. It's optimized for parsing messy user input (forms), not date manipulation. If you need date arithmetic, duration formatting, or timezone support, use a dedicated date library.
|
|
177
|
+
|
|
178
|
+
### Are TypeScript types included?
|
|
179
|
+
|
|
180
|
+
Yes. Type declarations are bundled in the package (`dist/index.d.ts`).
|
|
181
|
+
|
|
182
|
+
### How strict is date validation?
|
|
183
|
+
|
|
184
|
+
`parseDate` is lenient — it tries to extract a valid date from messy input. A nonexistent date like "feb30" or "Apr 31" will 'wrap' to the next month and return 'March 2' or 'May 1' of the current year. Completely invalid dates or nonsensical input returns `Invalid Date`. Use `isDate()` to verify the result is valid before using it.
|
|
185
|
+
|
|
186
|
+
### What counts as a valid email?
|
|
187
|
+
|
|
188
|
+
The `isEmail` function uses a practical regex that covers most real-world addresses: alphanumeric local parts with common special characters, domain with at least one dot, and a 2+ character TLD. By design, it's not fully RFC 5322 compliant (which allows quoted strings and other rarities).
|
|
189
|
+
|
|
190
|
+
### Does `isNANPTel` require dashes?
|
|
191
|
+
|
|
192
|
+
`isNANPTel` validates the format `###-###-####` with dashes. Use `parseNANPTel` first to normalize various inputs (spaces, dots, parentheses) into this format, then validate.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { isFormControl, isType, monthToNumber, yearToFull, parseDate, parseDateTime, parseTime, parseTimeToString, parseDateTimeToString, formatDateTime, momentToFPFormat, parseDateToString, isDate, isDateInRange, parseRelativeDate, isMeridiem, isDateTime, isTime, isEmail, parseNANPTel, isNANPTel, parseInteger, isNumber, parseNumber, isInteger, parseBytes, formatBytes, parseUrl, isUrl, parseZip, isZip, parsePostalCA, isPostalCA, isColor, parseColor, normalizeValidationResult, } from './src/validator-utils';
|
|
@@ -20,6 +20,11 @@ export declare function parseDateToString(value: string | Date, format?: string)
|
|
|
20
20
|
export declare function parseDateTimeToString(value: string | Date, format?: string): string;
|
|
21
21
|
export declare function parseTimeToString(value: string, format?: string): string;
|
|
22
22
|
export declare function monthToNumber(str: string | number): number;
|
|
23
|
+
/**
|
|
24
|
+
* Parses a relative date offset like "-30d", "+2w", "30d", "-6m", "+1y"
|
|
25
|
+
* Returns a Date object relative to today, or null if invalid
|
|
26
|
+
*/
|
|
27
|
+
export declare function parseRelativeDate(offset: string): Date | null;
|
|
23
28
|
export declare function isDateInRange(date: Date, range: string): boolean;
|
|
24
29
|
export declare function isFormControl(el: any): boolean;
|
|
25
30
|
export declare function isType(el: HTMLInputElement | HTMLTextAreaElement, types: string | string[]): boolean;
|
|
@@ -30,6 +35,20 @@ export declare function parseInteger(value: string): string;
|
|
|
30
35
|
export declare function isInteger(value: string): boolean;
|
|
31
36
|
export declare function parseNumber(value: string): string;
|
|
32
37
|
export declare function isNumber(value: string): boolean;
|
|
38
|
+
/**
|
|
39
|
+
* Parses a human-readable byte size string into bytes.
|
|
40
|
+
* Accepts: 500, 5B, 5K, 5KB, 5KiB, 5Ki, 5M, 5MB, 5MiB, etc.
|
|
41
|
+
* SI units (KB, MB) use powers of 1000; binary units (KiB, MiB) use powers of 1024.
|
|
42
|
+
* Returns NaN for invalid input.
|
|
43
|
+
*/
|
|
44
|
+
export declare function parseBytes(value: string): number;
|
|
45
|
+
/**
|
|
46
|
+
* Formats bytes as a human-readable string.
|
|
47
|
+
* @param bytes - The number of bytes
|
|
48
|
+
* @param decimal - If true (default), uses SI units (1000-based). If false, uses binary (1024-based).
|
|
49
|
+
* @returns Formatted string like "1.5 MB" or "512 B"
|
|
50
|
+
*/
|
|
51
|
+
export declare function formatBytes(bytes: number, decimal?: boolean): string;
|
|
33
52
|
export declare function parseUrl(value: string): string;
|
|
34
53
|
export declare function isUrl(value: string): boolean;
|
|
35
54
|
export declare function parseZip(value: string): string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const C=/^(?:[a-z+]+:)?\/\//i,R=/^(?:[-a-z+]+:)?\/\//i,H=/^\d{5}(-\d{4})?$/,_=/^[ABCEGHJKLMNPRSTVXY][0-9][ABCEGHJKLMNPRSTVWXYZ] ?[0-9][ABCEGHJKLMNPRSTVWXYZ][0-9]$/,I=/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?)*\.[a-zA-Z]{2,}$/,B=/^\d{3}-\d{3}-\d{4}$/,L=/^-?\d*$/,P=/^-?\d*\.?\d*$/,y={midnight:0,noon:12,midday:12};function D(e){let t=e.trim().toLowerCase().replace(/\.+$/g,"");if(t==="now"){const u=new Date;return{hour:u.getHours(),minute:u.getMinutes(),second:u.getSeconds()}}if(t in y)return{hour:y[t],minute:0,second:0};t=t.replace(/\s+/g,"").replace(/\.+$/g,"");const s=t.replace(/^(\d{1,2})(\d{2})([ap]?m?\.?)$/i,"$1:$2$3").match(/^(\d{1,2})(?::(\d{1,2}))?(?::(\d{1,2}))?\s*([ap])?\.?m?\.?$/i);if(!s)return null;let i=+s[1],o=+(s[2]||0),c=+(s[3]||0);const a=s[4]?.toLowerCase();return a==="p"&&i<12&&(i+=12),a==="a"&&i===12&&(i=0),i>23||o>59||c>59?null:{hour:i,minute:o,second:c}}function Z(e){return D(e)!==null}function z(e){return/^[ap]\.?m?\.?$/i.test(e.replace(/\s/g,""))}const O="jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec",E=new RegExp(`(${O})[a-z]*`,"i");function j(e){return new Date(`1 ${e} 2000`).getMonth()}function h(e){if(typeof e=="string"&&(e=parseInt(e.replace(/\D/g,""))),e>99)return e;const t=(new Date().getFullYear()+20)%100;return e+(e<t?2e3:1900)}function T(e){if(e instanceof Date)return e;let t=e.trim().toLowerCase();const n=new Date(new Date().setHours(0,0,0,0));if(/^(now|today)$/.test(t))return n;if(t==="yesterday")return new Date(n.setDate(n.getDate()-1));if(t==="tomorrow")return new Date(new Date().setHours(0,0,0,0)+864e5);const s=e.match(/(\d{2,4})\s*[年년]\s*(\d{1,2})\s*[月월]\s*(\d{1,2})\s*[日일]?/);if(s)return new Date(h(+s[1]),+s[2]-1,+s[3],0,0,0);t=t.replace(/\b(mon|tue|wed|thu|fri|sat|sun|lun|mar(?:di|tes)|mer|jeu|ven|sam|dim|dom)[a-z]*\.?\b/gi,"").trim();let i=0,o=0,c=0;const a=t.match(/(\d{1,2}:\d{2}(?::\d{2})?\s*[ap]?\.?m?\.?)/i);if(a){const f=D(a[1]);if(f&&({hour:i,minute:o,second:c}=f),t=t.replace(a[0],"").trim(),!t||t.length<=2){const g=new Date;return new Date(g.getFullYear(),g.getMonth(),g.getDate(),i,o,c)}}if(/^\d{8}$/.test(t))return new Date(+t.slice(0,4),+t.slice(4,6)-1,+t.slice(6,8),i,o,c);if(/^\d{6}$/.test(t))return new Date(h(+t.slice(0,2)),+t.slice(2,4)-1,+t.slice(4,6),i,o,c);const u=t.match(E);let d=-1,r=0,l=0;u&&(d=j(u[1]),t=t.replace(u[0]," ").trim());const M=t.match(/'(\d{2})\b/);M&&(r=h(+M[1]),t=t.replace(M[0]," ").trim());const m=t.match(/\d+/g)?.map(Number)||[];if(d>=0)m.length>=2?m[0]>99?(r=m[0],l=m[1]):m[1]>99?(r=m[1],l=m[0]):m[0]>31?(l=m[1],r=h(m[0])):m[1]>31?(l=m[0],r=h(m[1])):(l=m[0],r=r||h(m[1])):m.length===1&&(l=m[0],r=r||new Date().getFullYear());else if(m.length>=3){const[f,g,p]=m;f>31?(r=f,d=g-1,l=p):f>12&&p>12?(l=f,d=g-1,r=p>31?p:h(p)):p>31||p>12?(d=f-1,l=g,r=p>31?p:h(p)):(g>12,d=f-1,l=g,r=h(p))}else m.length===2&&(d=m[0]-1,l=m[1],r=r||new Date().getFullYear());return r&&d>=0&&l&&l>=1&&l<=31?new Date(r>99?r:h(r),d,l,i,o,c):new Date("")}function b(e){if(e instanceof Date)return e;let t=e.trim();if(t.length<3)return null;if(t=t.replace(/(\d)T(\d)/i,"$1 $2"),t=t.replace(/(^|[\sT])(\d{1,2})\.(\d{1,2})(?:\.(\d{1,2}))?(?=\s*[ap]\.?m?\.?\b|(?:\s|$))/gi,(a,u,d,r,l)=>`${u}${l?`${d}:${r}:${l}`:`${d}:${r}`}`),/^now$/i.test(t)){const a=new Date;return a.setMilliseconds(0),a}if(/^(noon|midday)$/i.test(t)){const a=new Date;return new Date(a.getFullYear(),a.getMonth(),a.getDate(),12,0,0)}if(/^midnight$/i.test(t)){const a=new Date;return new Date(a.getFullYear(),a.getMonth(),a.getDate(),0,0,0)}let n=null,s=t;const i=[/\bmidnight\b/i,/\bmidday\b/i,/(\d{1,2}:\d{1,2}(?::\d{2})?)\s*([ap]\.?m?\.?)?/i,/\b(\d{1,2})\s*([ap]\.?m?\.?)\b/i,/\b(\d{3,4})([ap])m?\b/i];for(const a of i){const u=t.match(a);if(u){const d=D(u[0]);if(d){n=d,s=t.replace(u[0]," ").replace(/[\s.]+$/g,"").replace(/\s+/g," ").trim();break}}}if(!n){const a=s.match(/^(\d{4}[\-\/\.\s]\d{1,2}[\-\/\.\s]\d{1,2}|\d{8})\s+(\d{1,6})(\s*[ap]\.?m?\.?)?(?:\s*(?:z|utc|gmt|[+-]\d{2}:?\d{2})\b)?$/i);if(a){const u=a[2],d=(a[3]||"").replace(/\s+/g,"");let r=u+d;u.length===6&&(r=`${u.slice(0,2)}:${u.slice(2,4)}:${u.slice(4,6)}${d}`);const l=D(r);l&&(n=l,s=a[1])}}if(!n){const a=s.match(/^(.+?)\s+(\d{1,2})(\s*[ap]\.?m?\.?)?$/i);if(a){const u=a[2]+(a[3]||""),d=D(u);d&&E.test(a[1])&&(n=d,s=a[1])}}if(n&&(!s||/^,?\s*$/.test(s))){const a=new Date;return new Date(a.getFullYear(),a.getMonth(),a.getDate(),n.hour,n.minute,n.second)}const o=T(s);if(isNaN(o.getTime()))return null;const c=n||{hour:0,minute:0,second:0};return new Date(o.getFullYear(),o.getMonth(),o.getDate(),c.hour,c.minute,c.second)}function Y(e,t="YYYY-MM-DD"){if(typeof e=="string"&&(e=T(e)),isNaN(e.getTime()))return"";const n=e.getFullYear(),s=e.getMonth(),i=e.getDate(),o=e.getDay(),c=e.getHours(),a=e.getMinutes(),u=e.getSeconds(),d=e.getMilliseconds(),r=(p,$=2)=>String(p).padStart($,"0"),l=c%12||12,M=c<12?"AM":"PM",m=["January","February","March","April","May","June","July","August","September","October","November","December"],f=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],g={YYYY:n,YY:String(n).slice(-2),MMMM:m[s],MMM:m[s].slice(0,3),MM:r(s+1),M:s+1,DD:r(i),D:i,dddd:f[o],ddd:f[o].slice(0,3),dd:f[o].slice(0,2),d:o,HH:r(c),H:c,hh:r(l),h:l,mm:r(a),m:a,ss:r(u),s:u,SSS:r(d,3),A:M,a:M.toLowerCase()};return t.replace(/\[([^\]]+)]|YYYY|YY|MMMM|MMM|MM|M|DD|D|dddd|ddd|dd|d|HH|H|hh|h|mm|m|ss|s|SSS|A|a/g,(p,$)=>$??String(g[p]))}const K={YYYY:"Y",YY:"y",MMMM:"F",MMM:"M",MM:"m",M:"n",DD:"d",D:"j",dddd:"l",ddd:"D",dd:"D",d:"w",HH:"H",H:"G",hh:"h",mm:"i",m:"i",ss:"S",s:"s",A:"K",a:"K"},U=/YYYY|YY|MMMM|MMM|MM|M|DD|D|dddd|ddd|dd|d|HH|H|hh|mm|m|ss|s|A|a/g;function x(e){return e.replace(U,t=>K[t])}function k(e){return typeof e!="string"&&!(e instanceof Date)?!1:!isNaN(T(e).getTime())}function G(e){if(typeof e!="string"&&!(e instanceof Date))return!1;const t=b(e);return t!==null&&!isNaN(t.getTime())}function V(e,t="YYYY-MMM-DD"){const n=T(e);return isNaN(n.getTime())?"":Y(n,t)}function J(e,t="YYYY-MMM-DD h:mm A"){const n=b(e);return n&&!isNaN(n.getTime())?Y(n,t):""}function W(e,t="h:mm A"){const n=D(e);if(!n)return"";const s=new Date;return s.setHours(n.hour,n.minute,n.second,0),Y(s,t)}const S={ja:0,en:0,fe:1,fé:1,ap:3,ab:3,av:3,mai:4,juin:5,juil:6,au:7,ag:7,ao:7,se:8,o:9,n:10,d:11};function X(e){if(typeof e=="number")return e-1;const t=parseInt(e);if(!isNaN(t))return t-1;const n=new Date(`1 ${e} 2000`).getMonth();if(!isNaN(n))return n;const s=e.toLowerCase();for(const i in S)if(s.startsWith(i))return S[i];throw new Error("Invalid month name: "+e)}function F(e){const t=e.match(/^([+-])?(\d+)([dwmy])$/i);if(!t)return null;const[,n,s,i]=t,o=parseInt(s)*(n==="-"?-1:1),c=new Date;switch(c.setHours(0,0,0,0),i.toLowerCase()){case"d":c.setDate(c.getDate()+o);break;case"w":c.setDate(c.getDate()+o*7);break;case"m":c.setMonth(c.getMonth()+o);break;case"y":c.setFullYear(c.getFullYear()+o);break}return c}const A=/(\d{1,2}:\d{2}|\d{1,2}\.\d{2}|\b\d{1,2}\s*[ap]\b|\b[ap]\.?m\.?\b|\bnoon\b|\bmidday\b|\bmidnight\b|\bnow\b|T\d{1,2})/i,q=/(\d{1,2}[-/.]\d{1,2}(?:[-/.]\d{2,4})?|\b\d{4}\b|\b\d{6,8}\b|\b(?:jan|feb|mar|apr|may|jun|jul|aug|sep|sept|oct|nov|dec)\b|\btoday\b|\btomorrow\b|\byesterday\b)/i;function v(e,t){if(t==="past")return e<=new Date;if(t==="future")return e.getTime()>=new Date().setHours(0,0,0,0);if(t==="today"){const r=new Date;return e.getFullYear()===r.getFullYear()&&e.getMonth()===r.getMonth()&&e.getDate()===r.getDate()}const n=r=>{const l=r.trim();if(!l)return{date:null,hasTime:!1,valid:!0};const M=F(l);if(M)return{date:M,hasTime:!1,valid:!0};const m=l.search(q);if(m===-1)return{date:null,hasTime:!1,valid:!1};const f=l.search(A);if(f!==-1&&f<m)return{date:null,hasTime:!1,valid:!1};const g=b(l);return g&&!isNaN(g.getTime())?{date:g,hasTime:A.test(l),valid:!0}:{date:null,hasTime:!1,valid:!1}};let s=null;if(t.includes(":"))for(let r=0;r<t.length;r+=1){if(t[r]!==":")continue;const l=n(t.slice(0,r)),M=n(t.slice(r+1));if(l.valid&&M.valid){s={start:l,end:M};break}}if(!s){const r=n(t);return r.valid&&r.date?r.hasTime?e.getTime()===r.date.getTime():e.getFullYear()===r.date.getFullYear()&&e.getMonth()===r.date.getMonth()&&e.getDate()===r.date.getDate():!0}const i=s.start,o=s.end,a=i.hasTime||o.hasTime?e.getTime():new Date(e.getFullYear(),e.getMonth(),e.getDate()).getTime();let u=null;i.date&&(u=i.hasTime?i.date.getTime():new Date(i.date.getFullYear(),i.date.getMonth(),i.date.getDate()).getTime());let d=null;return o.date&&(d=o.hasTime?o.date.getTime():new Date(o.date.getFullYear(),o.date.getMonth(),o.date.getDate(),23,59,59,999).getTime()),!(u!==null&&a<u||d!==null&&a>d)}function Q(e){return e instanceof HTMLInputElement||e instanceof HTMLSelectElement||e instanceof HTMLTextAreaElement}function ee(e,t){return typeof t=="string"&&(t=[t]),t.includes(e.dataset.type||"")||t.includes(e.type)}function te(e){return e.length<=255&&I.test(e)}function ne(e){return e.replace(/^[^2-90]+/g,"").replace(/(\d\d\d).*?(\d\d\d).*?(\d\d\d\d)(.*)/,"$1-$2-$3$4")}function re(e){return B.test(e)}function se(e){return e.replace(/[^0-9]/g,"")}function ie(e){return L.test(e)}function ae(e){const t=e.replace(/[^\-0-9.]/g,"");let n="",s=!1,i=!1;for(let o=0;o<t.length;o+=1){const c=t[o];if(c==="-"){!i&&n.length===0&&(n+="-",i=!0);continue}if(c==="."){s||(n+=".",s=!0);continue}n+=c}return n}function oe(e){return P.test(e)}const ce={"":1,K:1e3,M:1e6,G:1e9,T:1e12},le={"":1,K:1024,M:1024**2,G:1024**3,T:1024**4};function ue(e){const n=e.trim().match(/^(\d+(?:\.\d*)?|\.\d+)\s*(B|Ki?B?|Mi?B?|Gi?B?|Ti?B?)?$/i);if(!n)return NaN;const s=Number.parseFloat(n[1]),i=n[2]?.toUpperCase()||"",o=i.includes("I"),c=i.replace(/I?B$/i,"").replace(/I$/i,"")||"";return s*(o?le:ce)[c]}function de(e,t=!0){const n=t?1e3:1024,s=["B","KB","MB","GB","TB"];if(e<n)return`${e} B`;let i=0,o=e;for(;o>=n&&i<s.length-1;)o/=n,i++;let c=Math.round(o*10)/10;return c>=n&&i<s.length-1&&(c=1,i++),`${c%1===0?c.toFixed(0):c.toFixed(1)} ${s[i]}`}function me(e){return e=e.trim(),C.test(e)?e:"https://"+e}function fe(e){return R.test(e)}function ge(e){return e=e.replace(/[^0-9]/g,"").replace(/(.{5})(.*)/,"$1-$2").trim(),e.length===6?e.replace(/-/,""):e}function pe(e){return H.test(e)}function Me(e){return e.toUpperCase().replace(/[^A-Z0-9]/g,"").replace(/(.{3})\s*(.*)/,"$1 $2").trim()}function he(e){return _.test(e)}function De(e){return["transparent","currentColor"].includes(e)?!0:!e.trim()||typeof CSS>"u"||!CSS.supports?!1:CSS.supports("color",e)}let w=null;const N=new Map;function Te(e){if(e=e.trim().toLowerCase(),["transparent","currentcolor"].includes(e))return e;if(N.has(e))return N.get(e);w||(w=document.createElement("canvas"),w.willReadFrequently=!0);const t=w.getContext("2d");t.fillStyle=e,t.fillRect(0,0,1,1);const n=t.getImageData(0,0,1,1).data,s="#"+("000000"+(n[0]<<16|n[1]<<8|n[2]).toString(16)).slice(-6);return N.set(e,s),s}function we(e){if(typeof e=="boolean")return{valid:e,error:!1,messages:[]};if(typeof e=="string")return{valid:!1,error:!1,messages:[e]};const t={valid:e.valid,error:e.error??!1,messages:[]};return typeof e.message=="string"?t.messages=[e.message]:typeof e.messages=="string"?t.messages=[e.messages]:Array.isArray(e.messages)&&(t.messages=e.messages),t}exports.formatBytes=de;exports.formatDateTime=Y;exports.isColor=De;exports.isDate=k;exports.isDateInRange=v;exports.isDateTime=G;exports.isEmail=te;exports.isFormControl=Q;exports.isInteger=ie;exports.isMeridiem=z;exports.isNANPTel=re;exports.isNumber=oe;exports.isPostalCA=he;exports.isTime=Z;exports.isType=ee;exports.isUrl=fe;exports.isZip=pe;exports.momentToFPFormat=x;exports.monthToNumber=X;exports.normalizeValidationResult=we;exports.parseBytes=ue;exports.parseColor=Te;exports.parseDate=T;exports.parseDateTime=b;exports.parseDateTimeToString=J;exports.parseDateToString=V;exports.parseInteger=se;exports.parseNANPTel=ne;exports.parseNumber=ae;exports.parsePostalCA=Me;exports.parseRelativeDate=F;exports.parseTime=D;exports.parseTimeToString=W;exports.parseUrl=me;exports.parseZip=ge;exports.yearToFull=h;
|
package/dist/validator-utils.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(i,T){typeof exports=="object"&&typeof module<"u"?T(exports):typeof define=="function"&&define.amd?define(["exports"],T):(i=typeof globalThis<"u"?globalThis:i||self,T(i.validatorUtils={}))})(this,(function(i){"use strict";const T=/^(?:[a-z+]+:)?\/\//i,C=/^(?:[-a-z+]+:)?\/\//i,H=/^\d{5}(-\d{4})?$/,R=/^[ABCEGHJKLMNPRSTVXY][0-9][ABCEGHJKLMNPRSTVWXYZ] ?[0-9][ABCEGHJKLMNPRSTVWXYZ][0-9]$/,F=/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?)*\.[a-zA-Z]{2,}$/,P=/^\d{3}-\d{3}-\d{4}$/,_=/^-?\d*$/,L=/^-?\d*\.?\d*$/;function h(e){let t=e.trim().toLowerCase();if(t==="now"){const o=new Date;return{hour:o.getHours(),minute:o.getMinutes(),second:o.getSeconds()}}if(t==="noon")return{hour:12,minute:0,second:0};t=t.replace(/\s+/g,"").replace(/\.+$/g,"");const r=t.replace(/^(\d{1,2})(\d{2})([ap]?m?\.?)$/i,"$1:$2$3").match(/^(\d{1,2})(?::(\d{1,2}))?(?::(\d{1,2}))?\s*([ap])?\.?m?\.?$/i);if(!r)return null;let l=+r[1],f=+(r[2]||0),m=+(r[3]||0);const s=r[4]?.toLowerCase();return s==="p"&&l<12&&(l+=12),s==="a"&&l===12&&(l=0),l>23||f>59||m>59?null:{hour:l,minute:f,second:m}}function I(e){return h(e)!==null}function Z(e){return/^[ap]\.?m?\.?$/i.test(e.replace(/\s/g,""))}const z="jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec",b=new RegExp(`(${z})[a-z]*`,"i");function O(e){return new Date(`1 ${e} 2000`).getMonth()}function D(e){if(typeof e=="string"&&(e=parseInt(e.replace(/\D/g,""))),e>99)return e;const t=(new Date().getFullYear()+20)%100;return e+(e<t?2e3:1900)}function Y(e){if(e instanceof Date)return e;let t=e.trim().toLowerCase();const n=new Date(new Date().setHours(0,0,0,0));if(/^(now|today)$/.test(t))return n;if(t==="tomorrow")return new Date(n.setDate(n.getDate()+1));t=t.replace(/\b(mon|tue|wed|thu|fri|sat|sun|lun|mar(?:di|tes)|mer|jeu|ven|sam|dim|dom)[a-z]*\.?\b/gi,"").trim();let r=0,l=0,f=0;const m=t.match(/(\d{1,2}:\d{2}(?::\d{2})?\s*[ap]?\.?m?\.?)/i);if(m){const M=h(m[1]);if(M&&({hour:r,minute:l,second:f}=M),t=t.replace(m[0],"").trim(),!t||t.length<=2){const d=new Date;return new Date(d.getFullYear(),d.getMonth(),d.getDate(),r,l,f)}}if(/^\d{8}$/.test(t))return new Date(+t.slice(0,4),+t.slice(4,6)-1,+t.slice(6,8),r,l,f);if(/^\d{6}$/.test(t))return new Date(D(+t.slice(0,2)),+t.slice(2,4)-1,+t.slice(4,6),r,l,f);const s=t.match(b);let o=-1,a=0,c=0;s&&(o=O(s[1]),t=t.replace(s[0]," ").trim());const p=t.match(/'(\d{2})\b/);p&&(a=D(+p[1]),t=t.replace(p[0]," ").trim());const u=t.match(/\d+/g)?.map(Number)||[];if(o>=0)u.length>=2?u[0]>99?(a=u[0],c=u[1]):u[1]>99?(a=u[1],c=u[0]):u[0]>31?(c=u[1],a=D(u[0])):u[1]>31?(c=u[0],a=D(u[1])):(c=u[0],a=a||D(u[1])):u.length===1&&(c=u[0],a=a||new Date().getFullYear());else if(u.length>=3){const[M,d,g]=u;M>31?(a=M,o=d-1,c=g):M>12&&g>12?(c=M,o=d-1,a=g>31?g:D(g)):g>31||g>12?(o=M-1,c=d,a=g>31?g:D(g)):(d>12,o=M-1,c=d,a=D(g))}else u.length===2&&(o=u[0]-1,c=u[1],a=a||new Date().getFullYear());return a&&o>=0&&c&&c>=1&&c<=31?new Date(a>99?a:D(a),o,c,r,l,f):new Date("")}function N(e){if(e instanceof Date)return e;let t=e.trim();if(t.length<3)return null;if(t=t.replace(/(\d)T(\d)/i,"$1 $2"),t=t.replace(/(^|[\sT])(\d{1,2})\.(\d{1,2})(?:\.(\d{1,2}))?(?=\s*[ap]\.?m?\.?\b|(?:\s|$))/gi,(s,o,a,c,p)=>`${o}${p?`${a}:${c}:${p}`:`${a}:${c}`}`),/^now$/i.test(t)){const s=new Date;return s.setMilliseconds(0),s}if(/^noon$/i.test(t)){const s=new Date;return new Date(s.getFullYear(),s.getMonth(),s.getDate(),12,0,0)}let n=null,r=t;const l=[/(\d{1,2}:\d{1,2}(?::\d{2})?)\s*([ap]\.?m?\.?)?/i,/\b(\d{1,2})\s*([ap]\.?m?\.?)\b/i,/\b(\d{3,4})([ap])m?\b/i];for(const s of l){const o=t.match(s);if(o){const a=h(o[0]);if(a){n=a,r=t.replace(o[0]," ").replace(/[\s.]+$/g,"").replace(/\s+/g," ").trim();break}}}if(!n){const s=r.match(/^(\d{4}[\-\/\.\s]\d{1,2}[\-\/\.\s]\d{1,2}|\d{8})\s+(\d{1,6})(\s*[ap]\.?m?\.?)?(?:\s*(?:z|utc|gmt|[+-]\d{2}:?\d{2})\b)?$/i);if(s){const o=s[2],a=(s[3]||"").replace(/\s+/g,"");let c=o+a;o.length===6&&(c=`${o.slice(0,2)}:${o.slice(2,4)}:${o.slice(4,6)}${a}`);const p=h(c);p&&(n=p,r=s[1])}}if(!n){const s=r.match(/^(.+?)\s+(\d{1,2})(\s*[ap]\.?m?\.?)?$/i);if(s){const o=s[2]+(s[3]||""),a=h(o);a&&b.test(s[1])&&(n=a,r=s[1])}}if(n&&(!r||/^,?\s*$/.test(r))){const s=new Date;return new Date(s.getFullYear(),s.getMonth(),s.getDate(),n.hour,n.minute,n.second)}const f=Y(r);if(isNaN(f.getTime()))return null;const m=n||{hour:0,minute:0,second:0};return new Date(f.getFullYear(),f.getMonth(),f.getDate(),m.hour,m.minute,m.second)}function $(e,t="YYYY-MM-DD"){if(typeof e=="string"&&(e=Y(e)),isNaN(e.getTime()))return"";const n=e.getFullYear(),r=e.getMonth(),l=e.getDate(),f=e.getDay(),m=e.getHours(),s=e.getMinutes(),o=e.getSeconds(),a=e.getMilliseconds(),c=(A,y=2)=>String(A).padStart(y,"0"),p=m%12||12,u=m<12?"AM":"PM",M=["January","February","March","April","May","June","July","August","September","October","November","December"],d=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],g={YYYY:n,YY:String(n).slice(-2),MMMM:M[r],MMM:M[r].slice(0,3),MM:c(r+1),M:r+1,DD:c(l),D:l,dddd:d[f],ddd:d[f].slice(0,3),dd:d[f].slice(0,2),d:f,HH:c(m),H:m,hh:c(p),h:p,mm:c(s),m:s,ss:c(o),s:o,SSS:c(a,3),A:u,a:u.toLowerCase()};return t.replace(/\[([^\]]+)]|YYYY|YY|MMMM|MMM|MM|M|DD|D|dddd|ddd|dd|d|HH|H|hh|h|mm|m|ss|s|SSS|A|a/g,(A,y)=>y??String(g[A]))}const j={YYYY:"Y",YY:"y",MMMM:"F",MMM:"M",MM:"m",M:"n",DD:"d",D:"j",dddd:"l",ddd:"D",dd:"D",d:"w",HH:"H",H:"G",hh:"h",mm:"i",m:"i",ss:"S",s:"s",A:"K",a:"K"},U=/YYYY|YY|MMMM|MMM|MM|M|DD|D|dddd|ddd|dd|d|HH|H|hh|mm|m|ss|s|A|a/g;function J(e){return e.replace(U,t=>j[t])}function K(e){return typeof e!="string"&&!(e instanceof Date)?!1:!isNaN(Y(e).getTime())}function V(e){if(typeof e!="string"&&!(e instanceof Date))return!1;const t=N(e);return t!==null&&!isNaN(t.getTime())}function G(e,t="YYYY-MMM-DD"){const n=Y(e);return isNaN(n.getTime())?"":$(n,t)}function W(e,t="YYYY-MMM-DD h:mm A"){const n=N(e);return n&&!isNaN(n.getTime())?$(n,t):""}function B(e,t="h:mm A"){const n=h(e);if(!n)return"";const r=new Date;return r.setHours(n.hour,n.minute,n.second,0),$(r,t)}const E={ja:0,en:0,fe:1,fé:1,ap:3,ab:3,av:3,mai:4,juin:5,juil:6,au:7,ag:7,ao:7,se:8,o:9,n:10,d:11};function k(e){if(typeof e=="number")return e-1;const t=parseInt(e);if(!isNaN(t))return t-1;const n=new Date(`1 ${e} 2000`).getMonth();if(!isNaN(n))return n;const r=e.toLowerCase();for(const l in E)if(r.startsWith(l))return E[l];throw new Error("Invalid month name: "+e)}function X(e,t){return!(t==="past"&&e>new Date||t==="future"&&e.getTime()<new Date().setHours(0,0,0,0))}function q(e){return e instanceof HTMLInputElement||e instanceof HTMLSelectElement||e instanceof HTMLTextAreaElement}function Q(e,t){return typeof t=="string"&&(t=[t]),t.includes(e.dataset.type||"")||t.includes(e.type)}function v(e){return e.length<=255&&F.test(e)}function x(e){return e.replace(/^[^2-90]+/g,"").replace(/(\d\d\d).*?(\d\d\d).*?(\d\d\d\d)(.*)/,"$1-$2-$3$4")}function ee(e){return P.test(e)}function te(e){return e.replace(/[^0-9]/g,"")}function ne(e){return _.test(e)}function ie(e){const t=e.replace(/[^\-0-9.]/g,"");let n="",r=!1,l=!1;for(let f=0;f<t.length;f+=1){const m=t[f];if(m==="-"){!l&&n.length===0&&(n+="-",l=!0);continue}if(m==="."){r||(n+=".",r=!0);continue}n+=m}return n}function re(e){return L.test(e)}function se(e){return e=e.trim(),T.test(e)?e:"https://"+e}function ae(e){return C.test(e)}function oe(e){return e=e.replace(/[^0-9]/g,"").replace(/(.{5})(.*)/,"$1-$2").trim(),e.length===6?e.replace(/-/,""):e}function ce(e){return H.test(e)}function ue(e){return e.toUpperCase().replace(/[^A-Z0-9]/g,"").replace(/(.{3})\s*(.*)/,"$1 $2").trim()}function le(e){return R.test(e)}function fe(e){return["transparent","currentColor"].includes(e)?!0:!e.trim()||typeof CSS>"u"||!CSS.supports?!1:CSS.supports("color",e)}let w=null;const S=new Map;function me(e){if(e=e.trim().toLowerCase(),["transparent","currentcolor"].includes(e))return e;if(S.has(e))return S.get(e);w||(w=document.createElement("canvas"),w.willReadFrequently=!0);const t=w.getContext("2d");t.fillStyle=e,t.fillRect(0,0,1,1);const n=t.getImageData(0,0,1,1).data,r="#"+("000000"+(n[0]<<16|n[1]<<8|n[2]).toString(16)).slice(-6);return S.set(e,r),r}function de(e){if(typeof e=="boolean")return{valid:e,error:!1,messages:[]};if(typeof e=="string")return{valid:!1,error:!1,messages:[e]};const t={valid:e.valid,error:e.error??!1,messages:[]};return typeof e.message=="string"?t.messages=[e.message]:typeof e.messages=="string"?t.messages=[e.messages]:Array.isArray(e.messages)&&(t.messages=e.messages),t}i.formatDateTime=$,i.isColor=fe,i.isDate=K,i.isDateInRange=X,i.isDateTime=V,i.isEmail=v,i.isFormControl=q,i.isInteger=ne,i.isMeridiem=Z,i.isNANPTel=ee,i.isNumber=re,i.isPostalCA=le,i.isTime=I,i.isType=Q,i.isUrl=ae,i.isZip=ce,i.momentToFPFormat=J,i.monthToNumber=k,i.normalizeValidationResult=de,i.parseColor=me,i.parseDate=Y,i.parseDateTime=N,i.parseDateTimeToString=W,i.parseDateToString=G,i.parseInteger=te,i.parseNANPTel=x,i.parseNumber=ie,i.parsePostalCA=ue,i.parseTime=h,i.parseTimeToString=B,i.parseUrl=se,i.parseZip=oe,i.yearToFull=D,Object.defineProperty(i,Symbol.toStringTag,{value:"Module"})}));
|
|
1
|
+
(function(o,w){typeof exports=="object"&&typeof module<"u"?w(exports):typeof define=="function"&&define.amd?define(["exports"],w):(o=typeof globalThis<"u"?globalThis:o||self,w(o.validatorUtils={}))})(this,(function(o){"use strict";const w=/^(?:[a-z+]+:)?\/\//i,H=/^(?:[-a-z+]+:)?\/\//i,_=/^\d{5}(-\d{4})?$/,I=/^[ABCEGHJKLMNPRSTVXY][0-9][ABCEGHJKLMNPRSTVWXYZ] ?[0-9][ABCEGHJKLMNPRSTVWXYZ][0-9]$/,B=/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?)*\.[a-zA-Z]{2,}$/,L=/^\d{3}-\d{3}-\d{4}$/,P=/^-?\d*$/,Z=/^-?\d*\.?\d*$/,A={midnight:0,noon:12,midday:12};function p(e){let t=e.trim().toLowerCase().replace(/\.+$/g,"");if(t==="now"){const d=new Date;return{hour:d.getHours(),minute:d.getMinutes(),second:d.getSeconds()}}if(t in A)return{hour:A[t],minute:0,second:0};t=t.replace(/\s+/g,"").replace(/\.+$/g,"");const s=t.replace(/^(\d{1,2})(\d{2})([ap]?m?\.?)$/i,"$1:$2$3").match(/^(\d{1,2})(?::(\d{1,2}))?(?::(\d{1,2}))?\s*([ap])?\.?m?\.?$/i);if(!s)return null;let r=+s[1],c=+(s[2]||0),l=+(s[3]||0);const a=s[4]?.toLowerCase();return a==="p"&&r<12&&(r+=12),a==="a"&&r===12&&(r=0),r>23||c>59||l>59?null:{hour:r,minute:c,second:l}}function z(e){return p(e)!==null}function j(e){return/^[ap]\.?m?\.?$/i.test(e.replace(/\s/g,""))}const O="jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec",E=new RegExp(`(${O})[a-z]*`,"i");function K(e){return new Date(`1 ${e} 2000`).getMonth()}function D(e){if(typeof e=="string"&&(e=parseInt(e.replace(/\D/g,""))),e>99)return e;const t=(new Date().getFullYear()+20)%100;return e+(e<t?2e3:1900)}function b(e){if(e instanceof Date)return e;let t=e.trim().toLowerCase();const n=new Date(new Date().setHours(0,0,0,0));if(/^(now|today)$/.test(t))return n;if(t==="yesterday")return new Date(n.setDate(n.getDate()-1));if(t==="tomorrow")return new Date(new Date().setHours(0,0,0,0)+864e5);const s=e.match(/(\d{2,4})\s*[年년]\s*(\d{1,2})\s*[月월]\s*(\d{1,2})\s*[日일]?/);if(s)return new Date(D(+s[1]),+s[2]-1,+s[3],0,0,0);t=t.replace(/\b(mon|tue|wed|thu|fri|sat|sun|lun|mar(?:di|tes)|mer|jeu|ven|sam|dim|dom)[a-z]*\.?\b/gi,"").trim();let r=0,c=0,l=0;const a=t.match(/(\d{1,2}:\d{2}(?::\d{2})?\s*[ap]?\.?m?\.?)/i);if(a){const g=p(a[1]);if(g&&({hour:r,minute:c,second:l}=g),t=t.replace(a[0],"").trim(),!t||t.length<=2){const M=new Date;return new Date(M.getFullYear(),M.getMonth(),M.getDate(),r,c,l)}}if(/^\d{8}$/.test(t))return new Date(+t.slice(0,4),+t.slice(4,6)-1,+t.slice(6,8),r,c,l);if(/^\d{6}$/.test(t))return new Date(D(+t.slice(0,2)),+t.slice(2,4)-1,+t.slice(4,6),r,c,l);const d=t.match(E);let m=-1,i=0,u=0;d&&(m=K(d[1]),t=t.replace(d[0]," ").trim());const T=t.match(/'(\d{2})\b/);T&&(i=D(+T[1]),t=t.replace(T[0]," ").trim());const f=t.match(/\d+/g)?.map(Number)||[];if(m>=0)f.length>=2?f[0]>99?(i=f[0],u=f[1]):f[1]>99?(i=f[1],u=f[0]):f[0]>31?(u=f[1],i=D(f[0])):f[1]>31?(u=f[0],i=D(f[1])):(u=f[0],i=i||D(f[1])):f.length===1&&(u=f[0],i=i||new Date().getFullYear());else if(f.length>=3){const[g,M,h]=f;g>31?(i=g,m=M-1,u=h):g>12&&h>12?(u=g,m=M-1,i=h>31?h:D(h)):h>31||h>12?(m=g-1,u=M,i=h>31?h:D(h)):(M>12,m=g-1,u=M,i=D(h))}else f.length===2&&(m=f[0]-1,u=f[1],i=i||new Date().getFullYear());return i&&m>=0&&u&&u>=1&&u<=31?new Date(i>99?i:D(i),m,u,r,c,l):new Date("")}function Y(e){if(e instanceof Date)return e;let t=e.trim();if(t.length<3)return null;if(t=t.replace(/(\d)T(\d)/i,"$1 $2"),t=t.replace(/(^|[\sT])(\d{1,2})\.(\d{1,2})(?:\.(\d{1,2}))?(?=\s*[ap]\.?m?\.?\b|(?:\s|$))/gi,(a,d,m,i,u)=>`${d}${u?`${m}:${i}:${u}`:`${m}:${i}`}`),/^now$/i.test(t)){const a=new Date;return a.setMilliseconds(0),a}if(/^(noon|midday)$/i.test(t)){const a=new Date;return new Date(a.getFullYear(),a.getMonth(),a.getDate(),12,0,0)}if(/^midnight$/i.test(t)){const a=new Date;return new Date(a.getFullYear(),a.getMonth(),a.getDate(),0,0,0)}let n=null,s=t;const r=[/\bmidnight\b/i,/\bmidday\b/i,/(\d{1,2}:\d{1,2}(?::\d{2})?)\s*([ap]\.?m?\.?)?/i,/\b(\d{1,2})\s*([ap]\.?m?\.?)\b/i,/\b(\d{3,4})([ap])m?\b/i];for(const a of r){const d=t.match(a);if(d){const m=p(d[0]);if(m){n=m,s=t.replace(d[0]," ").replace(/[\s.]+$/g,"").replace(/\s+/g," ").trim();break}}}if(!n){const a=s.match(/^(\d{4}[\-\/\.\s]\d{1,2}[\-\/\.\s]\d{1,2}|\d{8})\s+(\d{1,6})(\s*[ap]\.?m?\.?)?(?:\s*(?:z|utc|gmt|[+-]\d{2}:?\d{2})\b)?$/i);if(a){const d=a[2],m=(a[3]||"").replace(/\s+/g,"");let i=d+m;d.length===6&&(i=`${d.slice(0,2)}:${d.slice(2,4)}:${d.slice(4,6)}${m}`);const u=p(i);u&&(n=u,s=a[1])}}if(!n){const a=s.match(/^(.+?)\s+(\d{1,2})(\s*[ap]\.?m?\.?)?$/i);if(a){const d=a[2]+(a[3]||""),m=p(d);m&&E.test(a[1])&&(n=m,s=a[1])}}if(n&&(!s||/^,?\s*$/.test(s))){const a=new Date;return new Date(a.getFullYear(),a.getMonth(),a.getDate(),n.hour,n.minute,n.second)}const c=b(s);if(isNaN(c.getTime()))return null;const l=n||{hour:0,minute:0,second:0};return new Date(c.getFullYear(),c.getMonth(),c.getDate(),l.hour,l.minute,l.second)}function $(e,t="YYYY-MM-DD"){if(typeof e=="string"&&(e=b(e)),isNaN(e.getTime()))return"";const n=e.getFullYear(),s=e.getMonth(),r=e.getDate(),c=e.getDay(),l=e.getHours(),a=e.getMinutes(),d=e.getSeconds(),m=e.getMilliseconds(),i=(h,S=2)=>String(h).padStart(S,"0"),u=l%12||12,T=l<12?"AM":"PM",f=["January","February","March","April","May","June","July","August","September","October","November","December"],g=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],M={YYYY:n,YY:String(n).slice(-2),MMMM:f[s],MMM:f[s].slice(0,3),MM:i(s+1),M:s+1,DD:i(r),D:r,dddd:g[c],ddd:g[c].slice(0,3),dd:g[c].slice(0,2),d:c,HH:i(l),H:l,hh:i(u),h:u,mm:i(a),m:a,ss:i(d),s:d,SSS:i(m,3),A:T,a:T.toLowerCase()};return t.replace(/\[([^\]]+)]|YYYY|YY|MMMM|MMM|MM|M|DD|D|dddd|ddd|dd|d|HH|H|hh|h|mm|m|ss|s|SSS|A|a/g,(h,S)=>S??String(M[h]))}const U={YYYY:"Y",YY:"y",MMMM:"F",MMM:"M",MM:"m",M:"n",DD:"d",D:"j",dddd:"l",ddd:"D",dd:"D",d:"w",HH:"H",H:"G",hh:"h",mm:"i",m:"i",ss:"S",s:"s",A:"K",a:"K"},k=/YYYY|YY|MMMM|MMM|MM|M|DD|D|dddd|ddd|dd|d|HH|H|hh|mm|m|ss|s|A|a/g;function G(e){return e.replace(k,t=>U[t])}function V(e){return typeof e!="string"&&!(e instanceof Date)?!1:!isNaN(b(e).getTime())}function J(e){if(typeof e!="string"&&!(e instanceof Date))return!1;const t=Y(e);return t!==null&&!isNaN(t.getTime())}function W(e,t="YYYY-MMM-DD"){const n=b(e);return isNaN(n.getTime())?"":$(n,t)}function X(e,t="YYYY-MMM-DD h:mm A"){const n=Y(e);return n&&!isNaN(n.getTime())?$(n,t):""}function v(e,t="h:mm A"){const n=p(e);if(!n)return"";const s=new Date;return s.setHours(n.hour,n.minute,n.second,0),$(s,t)}const F={ja:0,en:0,fe:1,fé:1,ap:3,ab:3,av:3,mai:4,juin:5,juil:6,au:7,ag:7,ao:7,se:8,o:9,n:10,d:11};function q(e){if(typeof e=="number")return e-1;const t=parseInt(e);if(!isNaN(t))return t-1;const n=new Date(`1 ${e} 2000`).getMonth();if(!isNaN(n))return n;const s=e.toLowerCase();for(const r in F)if(s.startsWith(r))return F[r];throw new Error("Invalid month name: "+e)}function C(e){const t=e.match(/^([+-])?(\d+)([dwmy])$/i);if(!t)return null;const[,n,s,r]=t,c=parseInt(s)*(n==="-"?-1:1),l=new Date;switch(l.setHours(0,0,0,0),r.toLowerCase()){case"d":l.setDate(l.getDate()+c);break;case"w":l.setDate(l.getDate()+c*7);break;case"m":l.setMonth(l.getMonth()+c);break;case"y":l.setFullYear(l.getFullYear()+c);break}return l}const R=/(\d{1,2}:\d{2}|\d{1,2}\.\d{2}|\b\d{1,2}\s*[ap]\b|\b[ap]\.?m\.?\b|\bnoon\b|\bmidday\b|\bmidnight\b|\bnow\b|T\d{1,2})/i,Q=/(\d{1,2}[-/.]\d{1,2}(?:[-/.]\d{2,4})?|\b\d{4}\b|\b\d{6,8}\b|\b(?:jan|feb|mar|apr|may|jun|jul|aug|sep|sept|oct|nov|dec)\b|\btoday\b|\btomorrow\b|\byesterday\b)/i;function x(e,t){if(t==="past")return e<=new Date;if(t==="future")return e.getTime()>=new Date().setHours(0,0,0,0);if(t==="today"){const i=new Date;return e.getFullYear()===i.getFullYear()&&e.getMonth()===i.getMonth()&&e.getDate()===i.getDate()}const n=i=>{const u=i.trim();if(!u)return{date:null,hasTime:!1,valid:!0};const T=C(u);if(T)return{date:T,hasTime:!1,valid:!0};const f=u.search(Q);if(f===-1)return{date:null,hasTime:!1,valid:!1};const g=u.search(R);if(g!==-1&&g<f)return{date:null,hasTime:!1,valid:!1};const M=Y(u);return M&&!isNaN(M.getTime())?{date:M,hasTime:R.test(u),valid:!0}:{date:null,hasTime:!1,valid:!1}};let s=null;if(t.includes(":"))for(let i=0;i<t.length;i+=1){if(t[i]!==":")continue;const u=n(t.slice(0,i)),T=n(t.slice(i+1));if(u.valid&&T.valid){s={start:u,end:T};break}}if(!s){const i=n(t);return i.valid&&i.date?i.hasTime?e.getTime()===i.date.getTime():e.getFullYear()===i.date.getFullYear()&&e.getMonth()===i.date.getMonth()&&e.getDate()===i.date.getDate():!0}const r=s.start,c=s.end,a=r.hasTime||c.hasTime?e.getTime():new Date(e.getFullYear(),e.getMonth(),e.getDate()).getTime();let d=null;r.date&&(d=r.hasTime?r.date.getTime():new Date(r.date.getFullYear(),r.date.getMonth(),r.date.getDate()).getTime());let m=null;return c.date&&(m=c.hasTime?c.date.getTime():new Date(c.date.getFullYear(),c.date.getMonth(),c.date.getDate(),23,59,59,999).getTime()),!(d!==null&&a<d||m!==null&&a>m)}function ee(e){return e instanceof HTMLInputElement||e instanceof HTMLSelectElement||e instanceof HTMLTextAreaElement}function te(e,t){return typeof t=="string"&&(t=[t]),t.includes(e.dataset.type||"")||t.includes(e.type)}function ne(e){return e.length<=255&&B.test(e)}function ie(e){return e.replace(/^[^2-90]+/g,"").replace(/(\d\d\d).*?(\d\d\d).*?(\d\d\d\d)(.*)/,"$1-$2-$3$4")}function se(e){return L.test(e)}function re(e){return e.replace(/[^0-9]/g,"")}function ae(e){return P.test(e)}function oe(e){const t=e.replace(/[^\-0-9.]/g,"");let n="",s=!1,r=!1;for(let c=0;c<t.length;c+=1){const l=t[c];if(l==="-"){!r&&n.length===0&&(n+="-",r=!0);continue}if(l==="."){s||(n+=".",s=!0);continue}n+=l}return n}function ce(e){return Z.test(e)}const le={"":1,K:1e3,M:1e6,G:1e9,T:1e12},ue={"":1,K:1024,M:1024**2,G:1024**3,T:1024**4};function de(e){const n=e.trim().match(/^(\d+(?:\.\d*)?|\.\d+)\s*(B|Ki?B?|Mi?B?|Gi?B?|Ti?B?)?$/i);if(!n)return NaN;const s=Number.parseFloat(n[1]),r=n[2]?.toUpperCase()||"",c=r.includes("I"),l=r.replace(/I?B$/i,"").replace(/I$/i,"")||"";return s*(c?ue:le)[l]}function me(e,t=!0){const n=t?1e3:1024,s=["B","KB","MB","GB","TB"];if(e<n)return`${e} B`;let r=0,c=e;for(;c>=n&&r<s.length-1;)c/=n,r++;let l=Math.round(c*10)/10;return l>=n&&r<s.length-1&&(l=1,r++),`${l%1===0?l.toFixed(0):l.toFixed(1)} ${s[r]}`}function fe(e){return e=e.trim(),w.test(e)?e:"https://"+e}function ge(e){return H.test(e)}function Me(e){return e=e.replace(/[^0-9]/g,"").replace(/(.{5})(.*)/,"$1-$2").trim(),e.length===6?e.replace(/-/,""):e}function he(e){return _.test(e)}function De(e){return e.toUpperCase().replace(/[^A-Z0-9]/g,"").replace(/(.{3})\s*(.*)/,"$1 $2").trim()}function Te(e){return I.test(e)}function pe(e){return["transparent","currentColor"].includes(e)?!0:!e.trim()||typeof CSS>"u"||!CSS.supports?!1:CSS.supports("color",e)}let y=null;const N=new Map;function we(e){if(e=e.trim().toLowerCase(),["transparent","currentcolor"].includes(e))return e;if(N.has(e))return N.get(e);y||(y=document.createElement("canvas"),y.willReadFrequently=!0);const t=y.getContext("2d");t.fillStyle=e,t.fillRect(0,0,1,1);const n=t.getImageData(0,0,1,1).data,s="#"+("000000"+(n[0]<<16|n[1]<<8|n[2]).toString(16)).slice(-6);return N.set(e,s),s}function be(e){if(typeof e=="boolean")return{valid:e,error:!1,messages:[]};if(typeof e=="string")return{valid:!1,error:!1,messages:[e]};const t={valid:e.valid,error:e.error??!1,messages:[]};return typeof e.message=="string"?t.messages=[e.message]:typeof e.messages=="string"?t.messages=[e.messages]:Array.isArray(e.messages)&&(t.messages=e.messages),t}o.formatBytes=me,o.formatDateTime=$,o.isColor=pe,o.isDate=V,o.isDateInRange=x,o.isDateTime=J,o.isEmail=ne,o.isFormControl=ee,o.isInteger=ae,o.isMeridiem=j,o.isNANPTel=se,o.isNumber=ce,o.isPostalCA=Te,o.isTime=z,o.isType=te,o.isUrl=ge,o.isZip=he,o.momentToFPFormat=G,o.monthToNumber=q,o.normalizeValidationResult=be,o.parseBytes=de,o.parseColor=we,o.parseDate=b,o.parseDateTime=Y,o.parseDateTimeToString=X,o.parseDateToString=W,o.parseInteger=re,o.parseNANPTel=ie,o.parseNumber=oe,o.parsePostalCA=De,o.parseRelativeDate=C,o.parseTime=p,o.parseTimeToString=v,o.parseUrl=fe,o.parseZip=Me,o.yearToFull=D,Object.defineProperty(o,Symbol.toStringTag,{value:"Module"})}));
|
|
@@ -0,0 +1,440 @@
|
|
|
1
|
+
const F = /^(?:[a-z+]+:)?\/\//i, H = /^(?:[-a-z+]+:)?\/\//i, _ = /^\d{5}(-\d{4})?$/, R = /^[ABCEGHJKLMNPRSTVXY][0-9][ABCEGHJKLMNPRSTVWXYZ] ?[0-9][ABCEGHJKLMNPRSTVWXYZ][0-9]$/, C = /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?)*\.[a-zA-Z]{2,}$/, I = /^\d{3}-\d{3}-\d{4}$/, B = /^-?\d*$/, L = /^-?\d*\.?\d*$/, N = { midnight: 0, noon: 12, midday: 12 };
|
|
2
|
+
function D(e) {
|
|
3
|
+
let t = e.trim().toLowerCase().replace(/\.+$/g, "");
|
|
4
|
+
if (t === "now") {
|
|
5
|
+
const l = /* @__PURE__ */ new Date();
|
|
6
|
+
return { hour: l.getHours(), minute: l.getMinutes(), second: l.getSeconds() };
|
|
7
|
+
}
|
|
8
|
+
if (t in N) return { hour: N[t], minute: 0, second: 0 };
|
|
9
|
+
t = t.replace(/\s+/g, "").replace(/\.+$/g, "");
|
|
10
|
+
const s = t.replace(/^(\d{1,2})(\d{2})([ap]?m?\.?)$/i, "$1:$2$3").match(/^(\d{1,2})(?::(\d{1,2}))?(?::(\d{1,2}))?\s*([ap])?\.?m?\.?$/i);
|
|
11
|
+
if (!s) return null;
|
|
12
|
+
let i = +s[1], o = +(s[2] || 0), c = +(s[3] || 0);
|
|
13
|
+
const a = s[4]?.toLowerCase();
|
|
14
|
+
return a === "p" && i < 12 && (i += 12), a === "a" && i === 12 && (i = 0), i > 23 || o > 59 || c > 59 ? null : { hour: i, minute: o, second: c };
|
|
15
|
+
}
|
|
16
|
+
function k(e) {
|
|
17
|
+
return D(e) !== null;
|
|
18
|
+
}
|
|
19
|
+
function G(e) {
|
|
20
|
+
return /^[ap]\.?m?\.?$/i.test(e.replace(/\s/g, ""));
|
|
21
|
+
}
|
|
22
|
+
const P = "jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec", A = new RegExp(`(${P})[a-z]*`, "i");
|
|
23
|
+
function z(e) {
|
|
24
|
+
return (/* @__PURE__ */ new Date(`1 ${e} 2000`)).getMonth();
|
|
25
|
+
}
|
|
26
|
+
function h(e) {
|
|
27
|
+
if (typeof e == "string" && (e = parseInt(e.replace(/\D/g, ""))), e > 99) return e;
|
|
28
|
+
const t = ((/* @__PURE__ */ new Date()).getFullYear() + 20) % 100;
|
|
29
|
+
return e + (e < t ? 2e3 : 1900);
|
|
30
|
+
}
|
|
31
|
+
function w(e) {
|
|
32
|
+
if (e instanceof Date) return e;
|
|
33
|
+
let t = e.trim().toLowerCase();
|
|
34
|
+
const n = new Date((/* @__PURE__ */ new Date()).setHours(0, 0, 0, 0));
|
|
35
|
+
if (/^(now|today)$/.test(t)) return n;
|
|
36
|
+
if (t === "yesterday") return new Date(n.setDate(n.getDate() - 1));
|
|
37
|
+
if (t === "tomorrow") return new Date((/* @__PURE__ */ new Date()).setHours(0, 0, 0, 0) + 864e5);
|
|
38
|
+
const s = e.match(/(\d{2,4})\s*[年년]\s*(\d{1,2})\s*[月월]\s*(\d{1,2})\s*[日일]?/);
|
|
39
|
+
if (s)
|
|
40
|
+
return new Date(h(+s[1]), +s[2] - 1, +s[3], 0, 0, 0);
|
|
41
|
+
t = t.replace(/\b(mon|tue|wed|thu|fri|sat|sun|lun|mar(?:di|tes)|mer|jeu|ven|sam|dim|dom)[a-z]*\.?\b/gi, "").trim();
|
|
42
|
+
let i = 0, o = 0, c = 0;
|
|
43
|
+
const a = t.match(/(\d{1,2}:\d{2}(?::\d{2})?\s*[ap]?\.?m?\.?)/i);
|
|
44
|
+
if (a) {
|
|
45
|
+
const f = D(a[1]);
|
|
46
|
+
if (f && ({ hour: i, minute: o, second: c } = f), t = t.replace(a[0], "").trim(), !t || t.length <= 2) {
|
|
47
|
+
const g = /* @__PURE__ */ new Date();
|
|
48
|
+
return new Date(g.getFullYear(), g.getMonth(), g.getDate(), i, o, c);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
if (/^\d{8}$/.test(t))
|
|
52
|
+
return new Date(+t.slice(0, 4), +t.slice(4, 6) - 1, +t.slice(6, 8), i, o, c);
|
|
53
|
+
if (/^\d{6}$/.test(t))
|
|
54
|
+
return new Date(h(+t.slice(0, 2)), +t.slice(2, 4) - 1, +t.slice(4, 6), i, o, c);
|
|
55
|
+
const l = t.match(A);
|
|
56
|
+
let d = -1, r = 0, u = 0;
|
|
57
|
+
l && (d = z(l[1]), t = t.replace(l[0], " ").trim());
|
|
58
|
+
const M = t.match(/'(\d{2})\b/);
|
|
59
|
+
M && (r = h(+M[1]), t = t.replace(M[0], " ").trim());
|
|
60
|
+
const m = t.match(/\d+/g)?.map(Number) || [];
|
|
61
|
+
if (d >= 0)
|
|
62
|
+
m.length >= 2 ? m[0] > 99 ? (r = m[0], u = m[1]) : m[1] > 99 ? (r = m[1], u = m[0]) : m[0] > 31 ? (u = m[1], r = h(m[0])) : m[1] > 31 ? (u = m[0], r = h(m[1])) : (u = m[0], r = r || h(m[1])) : m.length === 1 && (u = m[0], r = r || (/* @__PURE__ */ new Date()).getFullYear());
|
|
63
|
+
else if (m.length >= 3) {
|
|
64
|
+
const [f, g, p] = m;
|
|
65
|
+
f > 31 ? (r = f, d = g - 1, u = p) : f > 12 && p > 12 ? (u = f, d = g - 1, r = p > 31 ? p : h(p)) : p > 31 || p > 12 ? (d = f - 1, u = g, r = p > 31 ? p : h(p)) : (g > 12, d = f - 1, u = g, r = h(p));
|
|
66
|
+
} else m.length === 2 && (d = m[0] - 1, u = m[1], r = r || (/* @__PURE__ */ new Date()).getFullYear());
|
|
67
|
+
return r && d >= 0 && u && u >= 1 && u <= 31 ? new Date(r > 99 ? r : h(r), d, u, i, o, c) : /* @__PURE__ */ new Date("");
|
|
68
|
+
}
|
|
69
|
+
function $(e) {
|
|
70
|
+
if (e instanceof Date) return e;
|
|
71
|
+
let t = e.trim();
|
|
72
|
+
if (t.length < 3) return null;
|
|
73
|
+
if (t = t.replace(/(\d)T(\d)/i, "$1 $2"), t = t.replace(
|
|
74
|
+
/(^|[\sT])(\d{1,2})\.(\d{1,2})(?:\.(\d{1,2}))?(?=\s*[ap]\.?m?\.?\b|(?:\s|$))/gi,
|
|
75
|
+
(a, l, d, r, u) => `${l}${u ? `${d}:${r}:${u}` : `${d}:${r}`}`
|
|
76
|
+
), /^now$/i.test(t)) {
|
|
77
|
+
const a = /* @__PURE__ */ new Date();
|
|
78
|
+
return a.setMilliseconds(0), a;
|
|
79
|
+
}
|
|
80
|
+
if (/^(noon|midday)$/i.test(t)) {
|
|
81
|
+
const a = /* @__PURE__ */ new Date();
|
|
82
|
+
return new Date(a.getFullYear(), a.getMonth(), a.getDate(), 12, 0, 0);
|
|
83
|
+
}
|
|
84
|
+
if (/^midnight$/i.test(t)) {
|
|
85
|
+
const a = /* @__PURE__ */ new Date();
|
|
86
|
+
return new Date(a.getFullYear(), a.getMonth(), a.getDate(), 0, 0, 0);
|
|
87
|
+
}
|
|
88
|
+
let n = null, s = t;
|
|
89
|
+
const i = [
|
|
90
|
+
/\bmidnight\b/i,
|
|
91
|
+
/\bmidday\b/i,
|
|
92
|
+
/(\d{1,2}:\d{1,2}(?::\d{2})?)\s*([ap]\.?m?\.?)?/i,
|
|
93
|
+
// 14:30, 2:30pm, 1:5
|
|
94
|
+
/\b(\d{1,2})\s*([ap]\.?m?\.?)\b/i,
|
|
95
|
+
// 2pm, 2p.m., 2 PM, 1P
|
|
96
|
+
/\b(\d{3,4})([ap])m?\b/i
|
|
97
|
+
// 1430pm, 230p, 1200AM
|
|
98
|
+
];
|
|
99
|
+
for (const a of i) {
|
|
100
|
+
const l = t.match(a);
|
|
101
|
+
if (l) {
|
|
102
|
+
const d = D(l[0]);
|
|
103
|
+
if (d) {
|
|
104
|
+
n = d, s = t.replace(l[0], " ").replace(/[\s.]+$/g, "").replace(/\s+/g, " ").trim();
|
|
105
|
+
break;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
if (!n) {
|
|
110
|
+
const a = s.match(
|
|
111
|
+
/^(\d{4}[\-\/\.\s]\d{1,2}[\-\/\.\s]\d{1,2}|\d{8})\s+(\d{1,6})(\s*[ap]\.?m?\.?)?(?:\s*(?:z|utc|gmt|[+-]\d{2}:?\d{2})\b)?$/i
|
|
112
|
+
);
|
|
113
|
+
if (a) {
|
|
114
|
+
const l = a[2], d = (a[3] || "").replace(/\s+/g, "");
|
|
115
|
+
let r = l + d;
|
|
116
|
+
l.length === 6 && (r = `${l.slice(0, 2)}:${l.slice(2, 4)}:${l.slice(4, 6)}${d}`);
|
|
117
|
+
const u = D(r);
|
|
118
|
+
u && (n = u, s = a[1]);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
if (!n) {
|
|
122
|
+
const a = s.match(/^(.+?)\s+(\d{1,2})(\s*[ap]\.?m?\.?)?$/i);
|
|
123
|
+
if (a) {
|
|
124
|
+
const l = a[2] + (a[3] || ""), d = D(l);
|
|
125
|
+
d && A.test(a[1]) && (n = d, s = a[1]);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
if (n && (!s || /^,?\s*$/.test(s))) {
|
|
129
|
+
const a = /* @__PURE__ */ new Date();
|
|
130
|
+
return new Date(a.getFullYear(), a.getMonth(), a.getDate(), n.hour, n.minute, n.second);
|
|
131
|
+
}
|
|
132
|
+
const o = w(s);
|
|
133
|
+
if (isNaN(o.getTime())) return null;
|
|
134
|
+
const c = n || { hour: 0, minute: 0, second: 0 };
|
|
135
|
+
return new Date(o.getFullYear(), o.getMonth(), o.getDate(), c.hour, c.minute, c.second);
|
|
136
|
+
}
|
|
137
|
+
function y(e, t = "YYYY-MM-DD") {
|
|
138
|
+
if (typeof e == "string" && (e = w(e)), isNaN(e.getTime())) return "";
|
|
139
|
+
const n = e.getFullYear(), s = e.getMonth(), i = e.getDate(), o = e.getDay(), c = e.getHours(), a = e.getMinutes(), l = e.getSeconds(), d = e.getMilliseconds(), r = (p, Y = 2) => String(p).padStart(Y, "0"), u = c % 12 || 12, M = c < 12 ? "AM" : "PM", m = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"], f = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"], g = {
|
|
140
|
+
YYYY: n,
|
|
141
|
+
YY: String(n).slice(-2),
|
|
142
|
+
MMMM: m[s],
|
|
143
|
+
MMM: m[s].slice(0, 3),
|
|
144
|
+
MM: r(s + 1),
|
|
145
|
+
M: s + 1,
|
|
146
|
+
DD: r(i),
|
|
147
|
+
D: i,
|
|
148
|
+
dddd: f[o],
|
|
149
|
+
ddd: f[o].slice(0, 3),
|
|
150
|
+
dd: f[o].slice(0, 2),
|
|
151
|
+
d: o,
|
|
152
|
+
HH: r(c),
|
|
153
|
+
H: c,
|
|
154
|
+
hh: r(u),
|
|
155
|
+
h: u,
|
|
156
|
+
mm: r(a),
|
|
157
|
+
m: a,
|
|
158
|
+
ss: r(l),
|
|
159
|
+
s: l,
|
|
160
|
+
SSS: r(d, 3),
|
|
161
|
+
A: M,
|
|
162
|
+
a: M.toLowerCase()
|
|
163
|
+
};
|
|
164
|
+
return t.replace(
|
|
165
|
+
/\[([^\]]+)]|YYYY|YY|MMMM|MMM|MM|M|DD|D|dddd|ddd|dd|d|HH|H|hh|h|mm|m|ss|s|SSS|A|a/g,
|
|
166
|
+
(p, Y) => Y ?? String(g[p])
|
|
167
|
+
);
|
|
168
|
+
}
|
|
169
|
+
const Z = {
|
|
170
|
+
YYYY: "Y",
|
|
171
|
+
YY: "y",
|
|
172
|
+
MMMM: "F",
|
|
173
|
+
MMM: "M",
|
|
174
|
+
MM: "m",
|
|
175
|
+
M: "n",
|
|
176
|
+
DD: "d",
|
|
177
|
+
D: "j",
|
|
178
|
+
dddd: "l",
|
|
179
|
+
ddd: "D",
|
|
180
|
+
dd: "D",
|
|
181
|
+
d: "w",
|
|
182
|
+
HH: "H",
|
|
183
|
+
H: "G",
|
|
184
|
+
hh: "h",
|
|
185
|
+
mm: "i",
|
|
186
|
+
m: "i",
|
|
187
|
+
ss: "S",
|
|
188
|
+
s: "s",
|
|
189
|
+
A: "K",
|
|
190
|
+
a: "K"
|
|
191
|
+
}, K = /YYYY|YY|MMMM|MMM|MM|M|DD|D|dddd|ddd|dd|d|HH|H|hh|mm|m|ss|s|A|a/g;
|
|
192
|
+
function V(e) {
|
|
193
|
+
return e.replace(K, (t) => Z[t]);
|
|
194
|
+
}
|
|
195
|
+
function J(e) {
|
|
196
|
+
return typeof e != "string" && !(e instanceof Date) ? !1 : !isNaN(w(e).getTime());
|
|
197
|
+
}
|
|
198
|
+
function W(e) {
|
|
199
|
+
if (typeof e != "string" && !(e instanceof Date)) return !1;
|
|
200
|
+
const t = $(e);
|
|
201
|
+
return t !== null && !isNaN(t.getTime());
|
|
202
|
+
}
|
|
203
|
+
function X(e, t = "YYYY-MMM-DD") {
|
|
204
|
+
const n = w(e);
|
|
205
|
+
return isNaN(n.getTime()) ? "" : y(n, t);
|
|
206
|
+
}
|
|
207
|
+
function q(e, t = "YYYY-MMM-DD h:mm A") {
|
|
208
|
+
const n = $(e);
|
|
209
|
+
return n && !isNaN(n.getTime()) ? y(n, t) : "";
|
|
210
|
+
}
|
|
211
|
+
function Q(e, t = "h:mm A") {
|
|
212
|
+
const n = D(e);
|
|
213
|
+
if (!n) return "";
|
|
214
|
+
const s = /* @__PURE__ */ new Date();
|
|
215
|
+
return s.setHours(n.hour, n.minute, n.second, 0), y(s, t);
|
|
216
|
+
}
|
|
217
|
+
const S = {
|
|
218
|
+
ja: 0,
|
|
219
|
+
en: 0,
|
|
220
|
+
fe: 1,
|
|
221
|
+
fé: 1,
|
|
222
|
+
ap: 3,
|
|
223
|
+
ab: 3,
|
|
224
|
+
av: 3,
|
|
225
|
+
mai: 4,
|
|
226
|
+
juin: 5,
|
|
227
|
+
juil: 6,
|
|
228
|
+
au: 7,
|
|
229
|
+
ag: 7,
|
|
230
|
+
ao: 7,
|
|
231
|
+
se: 8,
|
|
232
|
+
o: 9,
|
|
233
|
+
n: 10,
|
|
234
|
+
d: 11
|
|
235
|
+
};
|
|
236
|
+
function v(e) {
|
|
237
|
+
if (typeof e == "number") return e - 1;
|
|
238
|
+
const t = parseInt(e);
|
|
239
|
+
if (!isNaN(t)) return t - 1;
|
|
240
|
+
const n = (/* @__PURE__ */ new Date(`1 ${e} 2000`)).getMonth();
|
|
241
|
+
if (!isNaN(n)) return n;
|
|
242
|
+
const s = e.toLowerCase();
|
|
243
|
+
for (const i in S) if (s.startsWith(i)) return S[i];
|
|
244
|
+
throw new Error("Invalid month name: " + e);
|
|
245
|
+
}
|
|
246
|
+
function O(e) {
|
|
247
|
+
const t = e.match(/^([+-])?(\d+)([dwmy])$/i);
|
|
248
|
+
if (!t) return null;
|
|
249
|
+
const [, n, s, i] = t, o = parseInt(s) * (n === "-" ? -1 : 1), c = /* @__PURE__ */ new Date();
|
|
250
|
+
switch (c.setHours(0, 0, 0, 0), i.toLowerCase()) {
|
|
251
|
+
case "d":
|
|
252
|
+
c.setDate(c.getDate() + o);
|
|
253
|
+
break;
|
|
254
|
+
case "w":
|
|
255
|
+
c.setDate(c.getDate() + o * 7);
|
|
256
|
+
break;
|
|
257
|
+
case "m":
|
|
258
|
+
c.setMonth(c.getMonth() + o);
|
|
259
|
+
break;
|
|
260
|
+
case "y":
|
|
261
|
+
c.setFullYear(c.getFullYear() + o);
|
|
262
|
+
break;
|
|
263
|
+
}
|
|
264
|
+
return c;
|
|
265
|
+
}
|
|
266
|
+
const E = /(\d{1,2}:\d{2}|\d{1,2}\.\d{2}|\b\d{1,2}\s*[ap]\b|\b[ap]\.?m\.?\b|\bnoon\b|\bmidday\b|\bmidnight\b|\bnow\b|T\d{1,2})/i, j = /(\d{1,2}[-/.]\d{1,2}(?:[-/.]\d{2,4})?|\b\d{4}\b|\b\d{6,8}\b|\b(?:jan|feb|mar|apr|may|jun|jul|aug|sep|sept|oct|nov|dec)\b|\btoday\b|\btomorrow\b|\byesterday\b)/i;
|
|
267
|
+
function ee(e, t) {
|
|
268
|
+
if (t === "past")
|
|
269
|
+
return e <= /* @__PURE__ */ new Date();
|
|
270
|
+
if (t === "future")
|
|
271
|
+
return e.getTime() >= (/* @__PURE__ */ new Date()).setHours(0, 0, 0, 0);
|
|
272
|
+
if (t === "today") {
|
|
273
|
+
const r = /* @__PURE__ */ new Date();
|
|
274
|
+
return e.getFullYear() === r.getFullYear() && e.getMonth() === r.getMonth() && e.getDate() === r.getDate();
|
|
275
|
+
}
|
|
276
|
+
const n = (r) => {
|
|
277
|
+
const u = r.trim();
|
|
278
|
+
if (!u) return { date: null, hasTime: !1, valid: !0 };
|
|
279
|
+
const M = O(u);
|
|
280
|
+
if (M) return { date: M, hasTime: !1, valid: !0 };
|
|
281
|
+
const m = u.search(j);
|
|
282
|
+
if (m === -1) return { date: null, hasTime: !1, valid: !1 };
|
|
283
|
+
const f = u.search(E);
|
|
284
|
+
if (f !== -1 && f < m) return { date: null, hasTime: !1, valid: !1 };
|
|
285
|
+
const g = $(u);
|
|
286
|
+
return g && !isNaN(g.getTime()) ? { date: g, hasTime: E.test(u), valid: !0 } : { date: null, hasTime: !1, valid: !1 };
|
|
287
|
+
};
|
|
288
|
+
let s = null;
|
|
289
|
+
if (t.includes(":"))
|
|
290
|
+
for (let r = 0; r < t.length; r += 1) {
|
|
291
|
+
if (t[r] !== ":") continue;
|
|
292
|
+
const u = n(t.slice(0, r)), M = n(t.slice(r + 1));
|
|
293
|
+
if (u.valid && M.valid) {
|
|
294
|
+
s = { start: u, end: M };
|
|
295
|
+
break;
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
if (!s) {
|
|
299
|
+
const r = n(t);
|
|
300
|
+
return r.valid && r.date ? r.hasTime ? e.getTime() === r.date.getTime() : e.getFullYear() === r.date.getFullYear() && e.getMonth() === r.date.getMonth() && e.getDate() === r.date.getDate() : !0;
|
|
301
|
+
}
|
|
302
|
+
const i = s.start, o = s.end, a = i.hasTime || o.hasTime ? e.getTime() : new Date(e.getFullYear(), e.getMonth(), e.getDate()).getTime();
|
|
303
|
+
let l = null;
|
|
304
|
+
i.date && (l = i.hasTime ? i.date.getTime() : new Date(i.date.getFullYear(), i.date.getMonth(), i.date.getDate()).getTime());
|
|
305
|
+
let d = null;
|
|
306
|
+
return o.date && (d = o.hasTime ? o.date.getTime() : new Date(o.date.getFullYear(), o.date.getMonth(), o.date.getDate(), 23, 59, 59, 999).getTime()), !(l !== null && a < l || d !== null && a > d);
|
|
307
|
+
}
|
|
308
|
+
function te(e) {
|
|
309
|
+
return e instanceof HTMLInputElement || e instanceof HTMLSelectElement || e instanceof HTMLTextAreaElement;
|
|
310
|
+
}
|
|
311
|
+
function ne(e, t) {
|
|
312
|
+
return typeof t == "string" && (t = [t]), t.includes(e.dataset.type || "") || t.includes(e.type);
|
|
313
|
+
}
|
|
314
|
+
function re(e) {
|
|
315
|
+
return e.length <= 255 && C.test(e);
|
|
316
|
+
}
|
|
317
|
+
function se(e) {
|
|
318
|
+
return e.replace(/^[^2-90]+/g, "").replace(/(\d\d\d).*?(\d\d\d).*?(\d\d\d\d)(.*)/, "$1-$2-$3$4");
|
|
319
|
+
}
|
|
320
|
+
function ie(e) {
|
|
321
|
+
return I.test(e);
|
|
322
|
+
}
|
|
323
|
+
function ae(e) {
|
|
324
|
+
return e.replace(/[^0-9]/g, "");
|
|
325
|
+
}
|
|
326
|
+
function oe(e) {
|
|
327
|
+
return B.test(e);
|
|
328
|
+
}
|
|
329
|
+
function ce(e) {
|
|
330
|
+
const t = e.replace(/[^\-0-9.]/g, "");
|
|
331
|
+
let n = "", s = !1, i = !1;
|
|
332
|
+
for (let o = 0; o < t.length; o += 1) {
|
|
333
|
+
const c = t[o];
|
|
334
|
+
if (c === "-") {
|
|
335
|
+
!i && n.length === 0 && (n += "-", i = !0);
|
|
336
|
+
continue;
|
|
337
|
+
}
|
|
338
|
+
if (c === ".") {
|
|
339
|
+
s || (n += ".", s = !0);
|
|
340
|
+
continue;
|
|
341
|
+
}
|
|
342
|
+
n += c;
|
|
343
|
+
}
|
|
344
|
+
return n;
|
|
345
|
+
}
|
|
346
|
+
function ue(e) {
|
|
347
|
+
return L.test(e);
|
|
348
|
+
}
|
|
349
|
+
const x = { "": 1, K: 1e3, M: 1e6, G: 1e9, T: 1e12 }, U = { "": 1, K: 1024, M: 1024 ** 2, G: 1024 ** 3, T: 1024 ** 4 };
|
|
350
|
+
function le(e) {
|
|
351
|
+
const n = e.trim().match(/^(\d+(?:\.\d*)?|\.\d+)\s*(B|Ki?B?|Mi?B?|Gi?B?|Ti?B?)?$/i);
|
|
352
|
+
if (!n) return NaN;
|
|
353
|
+
const s = Number.parseFloat(n[1]), i = n[2]?.toUpperCase() || "", o = i.includes("I"), c = i.replace(/I?B$/i, "").replace(/I$/i, "") || "";
|
|
354
|
+
return s * (o ? U : x)[c];
|
|
355
|
+
}
|
|
356
|
+
function de(e, t = !0) {
|
|
357
|
+
const n = t ? 1e3 : 1024, s = ["B", "KB", "MB", "GB", "TB"];
|
|
358
|
+
if (e < n) return `${e} B`;
|
|
359
|
+
let i = 0, o = e;
|
|
360
|
+
for (; o >= n && i < s.length - 1; )
|
|
361
|
+
o /= n, i++;
|
|
362
|
+
let c = Math.round(o * 10) / 10;
|
|
363
|
+
return c >= n && i < s.length - 1 && (c = 1, i++), `${c % 1 === 0 ? c.toFixed(0) : c.toFixed(1)} ${s[i]}`;
|
|
364
|
+
}
|
|
365
|
+
function me(e) {
|
|
366
|
+
return e = e.trim(), F.test(e) ? e : "https://" + e;
|
|
367
|
+
}
|
|
368
|
+
function fe(e) {
|
|
369
|
+
return H.test(e);
|
|
370
|
+
}
|
|
371
|
+
function ge(e) {
|
|
372
|
+
return e = e.replace(/[^0-9]/g, "").replace(/(.{5})(.*)/, "$1-$2").trim(), e.length === 6 ? e.replace(/-/, "") : e;
|
|
373
|
+
}
|
|
374
|
+
function pe(e) {
|
|
375
|
+
return _.test(e);
|
|
376
|
+
}
|
|
377
|
+
function Me(e) {
|
|
378
|
+
return e.toUpperCase().replace(/[^A-Z0-9]/g, "").replace(/(.{3})\s*(.*)/, "$1 $2").trim();
|
|
379
|
+
}
|
|
380
|
+
function he(e) {
|
|
381
|
+
return R.test(e);
|
|
382
|
+
}
|
|
383
|
+
function De(e) {
|
|
384
|
+
return ["transparent", "currentColor"].includes(e) ? !0 : !e.trim() || typeof CSS > "u" || !CSS.supports ? !1 : CSS.supports("color", e);
|
|
385
|
+
}
|
|
386
|
+
let T = null;
|
|
387
|
+
const b = /* @__PURE__ */ new Map();
|
|
388
|
+
function Te(e) {
|
|
389
|
+
if (e = e.trim().toLowerCase(), ["transparent", "currentcolor"].includes(e)) return e;
|
|
390
|
+
if (b.has(e)) return b.get(e);
|
|
391
|
+
T || (T = document.createElement("canvas"), T.willReadFrequently = !0);
|
|
392
|
+
const t = T.getContext("2d");
|
|
393
|
+
t.fillStyle = e, t.fillRect(0, 0, 1, 1);
|
|
394
|
+
const n = t.getImageData(0, 0, 1, 1).data, s = "#" + ("000000" + (n[0] << 16 | n[1] << 8 | n[2]).toString(16)).slice(-6);
|
|
395
|
+
return b.set(e, s), s;
|
|
396
|
+
}
|
|
397
|
+
function we(e) {
|
|
398
|
+
if (typeof e == "boolean") return { valid: e, error: !1, messages: [] };
|
|
399
|
+
if (typeof e == "string") return { valid: !1, error: !1, messages: [e] };
|
|
400
|
+
const t = { valid: e.valid, error: e.error ?? !1, messages: [] };
|
|
401
|
+
return typeof e.message == "string" ? t.messages = [e.message] : typeof e.messages == "string" ? t.messages = [e.messages] : Array.isArray(e.messages) && (t.messages = e.messages), t;
|
|
402
|
+
}
|
|
403
|
+
export {
|
|
404
|
+
de as formatBytes,
|
|
405
|
+
y as formatDateTime,
|
|
406
|
+
De as isColor,
|
|
407
|
+
J as isDate,
|
|
408
|
+
ee as isDateInRange,
|
|
409
|
+
W as isDateTime,
|
|
410
|
+
re as isEmail,
|
|
411
|
+
te as isFormControl,
|
|
412
|
+
oe as isInteger,
|
|
413
|
+
G as isMeridiem,
|
|
414
|
+
ie as isNANPTel,
|
|
415
|
+
ue as isNumber,
|
|
416
|
+
he as isPostalCA,
|
|
417
|
+
k as isTime,
|
|
418
|
+
ne as isType,
|
|
419
|
+
fe as isUrl,
|
|
420
|
+
pe as isZip,
|
|
421
|
+
V as momentToFPFormat,
|
|
422
|
+
v as monthToNumber,
|
|
423
|
+
we as normalizeValidationResult,
|
|
424
|
+
le as parseBytes,
|
|
425
|
+
Te as parseColor,
|
|
426
|
+
w as parseDate,
|
|
427
|
+
$ as parseDateTime,
|
|
428
|
+
q as parseDateTimeToString,
|
|
429
|
+
X as parseDateToString,
|
|
430
|
+
ae as parseInteger,
|
|
431
|
+
se as parseNANPTel,
|
|
432
|
+
ce as parseNumber,
|
|
433
|
+
Me as parsePostalCA,
|
|
434
|
+
O as parseRelativeDate,
|
|
435
|
+
D as parseTime,
|
|
436
|
+
Q as parseTimeToString,
|
|
437
|
+
me as parseUrl,
|
|
438
|
+
ge as parseZip,
|
|
439
|
+
h as yearToFull
|
|
440
|
+
};
|
package/package.json
CHANGED
|
@@ -1,23 +1,24 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jdlien/validator-utils",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.2.0",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"
|
|
6
|
-
"module": "dist/validator-utils.
|
|
7
|
-
"
|
|
8
|
-
"
|
|
5
|
+
"main": "dist/validator-utils.cjs",
|
|
6
|
+
"module": "dist/validator-utils.mjs",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/validator-utils.mjs",
|
|
12
|
+
"require": "./dist/validator-utils.cjs",
|
|
13
|
+
"default": "./dist/validator-utils.mjs"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
9
16
|
"files": [
|
|
10
17
|
"dist"
|
|
11
18
|
],
|
|
19
|
+
"unpkg": "dist/validator-utils.js",
|
|
20
|
+
"jsdelivr": "dist/validator-utils.js",
|
|
12
21
|
"description": "Validation and sanitization functions used by @jdlien/Validator.",
|
|
13
|
-
"scripts": {
|
|
14
|
-
"dev": "vite",
|
|
15
|
-
"build": "vite build && tsc --emitDeclarationOnly",
|
|
16
|
-
"size:wire": "node scripts/measure-wire-size.mjs",
|
|
17
|
-
"preview": "vite preview",
|
|
18
|
-
"test": "vitest",
|
|
19
|
-
"coverage": "vitest --coverage"
|
|
20
|
-
},
|
|
21
22
|
"repository": {
|
|
22
23
|
"type": "git",
|
|
23
24
|
"url": "git+https://github.com/jdlien/validator-utils.git"
|
|
@@ -27,7 +28,7 @@
|
|
|
27
28
|
},
|
|
28
29
|
"keywords": [
|
|
29
30
|
"validation",
|
|
30
|
-
"
|
|
31
|
+
"utilities",
|
|
31
32
|
"sanitization",
|
|
32
33
|
"date",
|
|
33
34
|
"time",
|
|
@@ -51,10 +52,15 @@
|
|
|
51
52
|
"vitest": "^4.0.18"
|
|
52
53
|
},
|
|
53
54
|
"sideEffects": false,
|
|
54
|
-
"
|
|
55
|
-
"
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
55
|
+
"scripts": {
|
|
56
|
+
"dev": "vite",
|
|
57
|
+
"build:lib": "pnpm build:lib:esm && pnpm build:lib:compat && tsc --emitDeclarationOnly",
|
|
58
|
+
"build:lib:esm": "vite build",
|
|
59
|
+
"build:lib:compat": "vite build --mode compat",
|
|
60
|
+
"build": "pnpm build:lib",
|
|
61
|
+
"size:wire": "node scripts/measure-wire-size.mjs",
|
|
62
|
+
"preview": "vite preview",
|
|
63
|
+
"test": "vitest",
|
|
64
|
+
"coverage": "vitest --coverage"
|
|
59
65
|
}
|
|
60
|
-
}
|
|
66
|
+
}
|