@js-utils-kit/valid 1.3.0 → 2.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/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- let e=require(`@js-utils-kit/types`);function t(e){return/[\p{P}]$/u.test(e)}function n(e){return/\s/.test(e)}function r(e){return/^[a-zA-Z]+$/.test(e)}function i(e){return e!=null}function a(e){return i(e)&&Array.isArray(e)}function o(){return typeof window<`u`&&window.document!==void 0}function s(e){return/^[a-z][a-zA-Z0-9]*$/.test(e)}function c(){return process.env.NODE_ENV===e.Environment.DEV}function l(e){if(typeof e!=`string`)throw TypeError(`Expected a string`);if(e.length>254)return!1;let t=e.split(`@`);if(t.length!==2)return!1;let[n,r]=t;return n.length===0||n.length>64||r.length===0||r.length>255?!1:!(!/^[a-zA-Z0-9_%+-]+(\.[a-zA-Z0-9_%+-]+)*$/.test(n)||!/^(?!.*\.\.)(?!-)[A-Za-z0-9-]{1,63}(?<!-)(\.[A-Za-z0-9-]{1,63}(?<!-))*\.[A-Za-z]{2,}$/.test(r))}function u(e){return e==null?!0:typeof e==`string`?e.trim().length===0:Array.isArray(e)?e.length===0:e instanceof Map||e instanceof Set?e.size===0:Object.prototype.toString.call(e)===`[object Object]`?Object.keys(e).length===0:!1}function d(e){return typeof e==`object`&&!!e&&Object.keys(e).length===0&&!a(e)}function f(e){return!e}function p(e){return/^[a-z0-9]+(-[a-z0-9]+)*$/.test(e)}function m(e){return/^[a-z]+$/.test(e)}function h(){return typeof process<`u`&&process.versions!==null&&process.versions.node!==null}function g(e){return typeof e==`object`&&!!e&&Object.keys(e).length>0&&!a(e)}function _(e){return e!=null&&typeof e==`string`}function v(e,t=!0){return _(e)?typeof e==`string`&&(t?e.trim().length>0:e.length>0):!1}function y(e){return!isNaN(Number(e))&&!isNaN(parseFloat(e))}function b(e){return i(e)&&typeof e==`object`&&!a(e)&&Object.getPrototypeOf(e)===Object.prototype}function x(e){return/^[A-Z][a-zA-Z0-9]*$/.test(e)}function S(){return process.env.NODE_ENV===e.Environment.PROD}function C(e){return/^[a-z0-9]+(_[a-z0-9]+)*$/.test(e)}function w(){return process.env.NODE_ENV===e.Environment.TEST}function T(e){return!!e}function E(e){return e==null}function D(e){return/^[A-Z]+$/.test(e)}function O(e){try{return new URL(e),!0}catch{return!1}}function k(e){return/^[A-Z]/.test(e)}exports.endsWithPunctuation=t,exports.hasWhitespace=n,exports.isAlphabetic=r,exports.isArray=a,exports.isBrowser=o,exports.isCamelCase=s,exports.isDefined=i,exports.isDev=c,exports.isEmail=l,exports.isEmpty=u,exports.isEmptyObject=d,exports.isFalsy=f,exports.isKebabCase=p,exports.isLowerCase=m,exports.isNode=h,exports.isNonEmptyObject=g,exports.isNonEmptyString=v,exports.isNumericString=y,exports.isObject=b,exports.isPascalCase=x,exports.isProd=S,exports.isSnakeCase=C,exports.isString=_,exports.isTest=w,exports.isTruthy=T,exports.isURL=O,exports.isUndefinedOrNull=E,exports.isUpperCase=D,exports.startsWithUppercase=k;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});function e(e){return/[\p{P}]$/u.test(e)}function t(e){return/\s/.test(e)}function n(e){return/^[a-zA-Z]+$/.test(e)}function r(e){return e!=null}function i(e){return r(e)&&Array.isArray(e)}function a(e){return/^[a-z][a-zA-Z0-9]*$/.test(e)}function o(e){if(typeof e!=`string`)throw TypeError(`Expected a string`);if(e.length>254)return!1;let t=e.split(`@`);if(t.length!==2)return!1;let[n,r]=t;return n.length===0||n.length>64||r.length===0||r.length>255?!1:!(!/^[a-zA-Z0-9_%+-]+(\.[a-zA-Z0-9_%+-]+)*$/.test(n)||!/^(?!.*\.\.)(?!-)[A-Za-z0-9-]{1,63}(?<!-)(\.[A-Za-z0-9-]{1,63}(?<!-))*\.[A-Za-z]{2,}$/.test(r))}function s(e){return e==null?!0:typeof e==`string`?e.trim().length===0:Array.isArray(e)?e.length===0:e instanceof Map||e instanceof Set?e.size===0:Object.prototype.toString.call(e)===`[object Object]`?Object.keys(e).length===0:!1}function c(e){return typeof e==`object`&&!!e&&Object.keys(e).length===0&&!i(e)}function l(e){return!e}function u(e){return/^[a-z0-9]+(-[a-z0-9]+)*$/.test(e)}function d(e){return/^[a-z]+$/.test(e)}function f(e){return typeof e==`object`&&!!e&&Object.keys(e).length>0&&!i(e)}function p(e){return e!=null&&typeof e==`string`}function m(e,t=!0){return p(e)?typeof e==`string`&&(t?e.trim().length>0:e.length>0):!1}function h(e){return!isNaN(Number(e))&&!isNaN(parseFloat(e))}function g(e){return r(e)&&typeof e==`object`&&!i(e)&&Object.getPrototypeOf(e)===Object.prototype}function _(e){return/^[A-Z][a-zA-Z0-9]*$/.test(e)}function v(e){return/^[a-z0-9]+(_[a-z0-9]+)*$/.test(e)}function y(e){return!!e}function b(e){return e==null}function x(e){return/^[A-Z]+$/.test(e)}function S(e){try{return new URL(e),!0}catch{return!1}}function C(e){return/^[A-Z]/.test(e)}exports.endsWithPunctuation=e,exports.hasWhitespace=t,exports.isAlphabetic=n,exports.isArray=i,exports.isCamelCase=a,exports.isDefined=r,exports.isEmail=o,exports.isEmpty=s,exports.isEmptyObject=c,exports.isFalsy=l,exports.isKebabCase=u,exports.isLowerCase=d,exports.isNonEmptyObject=f,exports.isNonEmptyString=m,exports.isNumericString=h,exports.isObject=g,exports.isPascalCase=_,exports.isSnakeCase=v,exports.isString=p,exports.isTruthy=y,exports.isURL=S,exports.isUndefinedOrNull=b,exports.isUpperCase=x,exports.startsWithUppercase=C;
package/dist/index.d.cts CHANGED
@@ -64,24 +64,6 @@ declare function isArray<T>(/** The value to check */
64
64
 
65
65
  value: T): boolean;
66
66
  //#endregion
67
- //#region src/isBrowser.d.ts
68
- /**
69
- * Checks if the current runtime environment is a browser.
70
- *
71
- * This function helps detect whether code is executing in a web browser
72
- * by confirming the existence of the global `window` and `document` objects.
73
- *
74
- * @returns `true` if running in a browser, otherwise `false`.
75
- *
76
- * @example
77
- * ```ts
78
- * if (isBrowser()) {
79
- * console.log('Running in a browser environment');
80
- * }
81
- * ```
82
- */
83
- declare function isBrowser(): boolean;
84
- //#endregion
85
67
  //#region src/isCamelCase.d.ts
86
68
  /**
87
69
  * Checks if a string is in camelCase format.
@@ -116,23 +98,6 @@ declare function isDefined<T>(/** The value to check */
116
98
 
117
99
  value: T): boolean;
118
100
  //#endregion
119
- //#region src/isDev.d.ts
120
- /**
121
- * Checks if the current environment is development.
122
- *
123
- * This is determined by comparing `process.env.NODE_ENV` with `'development'`.
124
- *
125
- * @returns `true` if `NODE_ENV` is set to development.
126
- *
127
- * @example
128
- * ```ts
129
- * if (isDev()) {
130
- * console.log('Dev mode enabled');
131
- * }
132
- * ```
133
- */
134
- declare function isDev(): boolean;
135
- //#endregion
136
101
  //#region src/isEmail.d.ts
137
102
  /**
138
103
  * Checks whether a given string is a valid email address.
@@ -289,27 +254,6 @@ declare function isLowerCase(/** The input string */
289
254
 
290
255
  value: string): boolean;
291
256
  //#endregion
292
- //#region src/isNode.d.ts
293
- /**
294
- * Checks if the current runtime environment is Node.js.
295
- *
296
- * This function is useful to conditionally execute server-side logic.
297
- * It detects the Node.js environment by verifying the presence of the
298
- * global `process` object and its `versions.node` property.
299
- *
300
- * @returns `true` if running in Node.js, otherwise `false`.
301
- *
302
- * @example
303
- * ```ts
304
- * if (isNode()) {
305
- * console.log('Running in Node.js environment');
306
- * }
307
- * ```
308
- *
309
- * @see {@link https://nodejs.org/api/process.html | Node.js process documentation}
310
- */
311
- declare function isNode(): boolean;
312
- //#endregion
313
257
  //#region src/isNonEmptyObject.d.ts
314
258
  /**
315
259
  * Checks if a value is a non-empty object (has at least one enumerable own property).
@@ -431,23 +375,6 @@ declare function isPascalCase(/** The input string */
431
375
 
432
376
  value: string): boolean;
433
377
  //#endregion
434
- //#region src/isProd.d.ts
435
- /**
436
- * Checks if the current environment is production.
437
- *
438
- * This is determined by comparing `process.env.NODE_ENV` with `'production'`.
439
- *
440
- * @returns `true` if `NODE_ENV` is set to production.
441
- *
442
- * @example
443
- * ```ts
444
- * if (isProd()) {
445
- * enableAnalytics();
446
- * }
447
- * ```
448
- */
449
- declare function isProd(): boolean;
450
- //#endregion
451
378
  //#region src/isSnakeCase.d.ts
452
379
  /**
453
380
  * Checks if a string is in snake_case format.
@@ -493,23 +420,6 @@ declare function isString<T>(/** The value to be checked */
493
420
 
494
421
  value: T): boolean;
495
422
  //#endregion
496
- //#region src/isTest.d.ts
497
- /**
498
- * Checks if the current environment is testing.
499
- *
500
- * This is determined by comparing `process.env.NODE_ENV` with `'test'`.
501
- *
502
- * @returns `true` if `NODE_ENV` is set to test.
503
- *
504
- * @example
505
- * ```ts
506
- * if (isTest()) {
507
- * mockDatabase();
508
- * }
509
- * ```
510
- */
511
- declare function isTest(): boolean;
512
- //#endregion
513
423
  //#region src/isTruthy.d.ts
514
424
  /**
515
425
  * Checks whether a value is truthy.
@@ -619,4 +529,4 @@ declare function startsWithUppercase(/** The input string to check */
619
529
 
620
530
  value: string): boolean;
621
531
  //#endregion
622
- export { endsWithPunctuation, hasWhitespace, isAlphabetic, isArray, isBrowser, isCamelCase, isDefined, isDev, isEmail, isEmpty, isEmptyObject, isFalsy, isKebabCase, isLowerCase, isNode, isNonEmptyObject, isNonEmptyString, isNumericString, isObject, isPascalCase, isProd, isSnakeCase, isString, isTest, isTruthy, isURL, isUndefinedOrNull, isUpperCase, startsWithUppercase };
532
+ export { endsWithPunctuation, hasWhitespace, isAlphabetic, isArray, isCamelCase, isDefined, isEmail, isEmpty, isEmptyObject, isFalsy, isKebabCase, isLowerCase, isNonEmptyObject, isNonEmptyString, isNumericString, isObject, isPascalCase, isSnakeCase, isString, isTruthy, isURL, isUndefinedOrNull, isUpperCase, startsWithUppercase };
package/dist/index.d.mts CHANGED
@@ -64,24 +64,6 @@ declare function isArray<T>(/** The value to check */
64
64
 
65
65
  value: T): boolean;
66
66
  //#endregion
67
- //#region src/isBrowser.d.ts
68
- /**
69
- * Checks if the current runtime environment is a browser.
70
- *
71
- * This function helps detect whether code is executing in a web browser
72
- * by confirming the existence of the global `window` and `document` objects.
73
- *
74
- * @returns `true` if running in a browser, otherwise `false`.
75
- *
76
- * @example
77
- * ```ts
78
- * if (isBrowser()) {
79
- * console.log('Running in a browser environment');
80
- * }
81
- * ```
82
- */
83
- declare function isBrowser(): boolean;
84
- //#endregion
85
67
  //#region src/isCamelCase.d.ts
86
68
  /**
87
69
  * Checks if a string is in camelCase format.
@@ -116,23 +98,6 @@ declare function isDefined<T>(/** The value to check */
116
98
 
117
99
  value: T): boolean;
118
100
  //#endregion
119
- //#region src/isDev.d.ts
120
- /**
121
- * Checks if the current environment is development.
122
- *
123
- * This is determined by comparing `process.env.NODE_ENV` with `'development'`.
124
- *
125
- * @returns `true` if `NODE_ENV` is set to development.
126
- *
127
- * @example
128
- * ```ts
129
- * if (isDev()) {
130
- * console.log('Dev mode enabled');
131
- * }
132
- * ```
133
- */
134
- declare function isDev(): boolean;
135
- //#endregion
136
101
  //#region src/isEmail.d.ts
137
102
  /**
138
103
  * Checks whether a given string is a valid email address.
@@ -289,27 +254,6 @@ declare function isLowerCase(/** The input string */
289
254
 
290
255
  value: string): boolean;
291
256
  //#endregion
292
- //#region src/isNode.d.ts
293
- /**
294
- * Checks if the current runtime environment is Node.js.
295
- *
296
- * This function is useful to conditionally execute server-side logic.
297
- * It detects the Node.js environment by verifying the presence of the
298
- * global `process` object and its `versions.node` property.
299
- *
300
- * @returns `true` if running in Node.js, otherwise `false`.
301
- *
302
- * @example
303
- * ```ts
304
- * if (isNode()) {
305
- * console.log('Running in Node.js environment');
306
- * }
307
- * ```
308
- *
309
- * @see {@link https://nodejs.org/api/process.html | Node.js process documentation}
310
- */
311
- declare function isNode(): boolean;
312
- //#endregion
313
257
  //#region src/isNonEmptyObject.d.ts
314
258
  /**
315
259
  * Checks if a value is a non-empty object (has at least one enumerable own property).
@@ -431,23 +375,6 @@ declare function isPascalCase(/** The input string */
431
375
 
432
376
  value: string): boolean;
433
377
  //#endregion
434
- //#region src/isProd.d.ts
435
- /**
436
- * Checks if the current environment is production.
437
- *
438
- * This is determined by comparing `process.env.NODE_ENV` with `'production'`.
439
- *
440
- * @returns `true` if `NODE_ENV` is set to production.
441
- *
442
- * @example
443
- * ```ts
444
- * if (isProd()) {
445
- * enableAnalytics();
446
- * }
447
- * ```
448
- */
449
- declare function isProd(): boolean;
450
- //#endregion
451
378
  //#region src/isSnakeCase.d.ts
452
379
  /**
453
380
  * Checks if a string is in snake_case format.
@@ -493,23 +420,6 @@ declare function isString<T>(/** The value to be checked */
493
420
 
494
421
  value: T): boolean;
495
422
  //#endregion
496
- //#region src/isTest.d.ts
497
- /**
498
- * Checks if the current environment is testing.
499
- *
500
- * This is determined by comparing `process.env.NODE_ENV` with `'test'`.
501
- *
502
- * @returns `true` if `NODE_ENV` is set to test.
503
- *
504
- * @example
505
- * ```ts
506
- * if (isTest()) {
507
- * mockDatabase();
508
- * }
509
- * ```
510
- */
511
- declare function isTest(): boolean;
512
- //#endregion
513
423
  //#region src/isTruthy.d.ts
514
424
  /**
515
425
  * Checks whether a value is truthy.
@@ -619,4 +529,4 @@ declare function startsWithUppercase(/** The input string to check */
619
529
 
620
530
  value: string): boolean;
621
531
  //#endregion
622
- export { endsWithPunctuation, hasWhitespace, isAlphabetic, isArray, isBrowser, isCamelCase, isDefined, isDev, isEmail, isEmpty, isEmptyObject, isFalsy, isKebabCase, isLowerCase, isNode, isNonEmptyObject, isNonEmptyString, isNumericString, isObject, isPascalCase, isProd, isSnakeCase, isString, isTest, isTruthy, isURL, isUndefinedOrNull, isUpperCase, startsWithUppercase };
532
+ export { endsWithPunctuation, hasWhitespace, isAlphabetic, isArray, isCamelCase, isDefined, isEmail, isEmpty, isEmptyObject, isFalsy, isKebabCase, isLowerCase, isNonEmptyObject, isNonEmptyString, isNumericString, isObject, isPascalCase, isSnakeCase, isString, isTruthy, isURL, isUndefinedOrNull, isUpperCase, startsWithUppercase };
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- import{Environment as e}from"@js-utils-kit/types";function t(e){return/[\p{P}]$/u.test(e)}function n(e){return/\s/.test(e)}function r(e){return/^[a-zA-Z]+$/.test(e)}function i(e){return e!=null}function a(e){return i(e)&&Array.isArray(e)}function o(){return typeof window<`u`&&window.document!==void 0}function s(e){return/^[a-z][a-zA-Z0-9]*$/.test(e)}function c(){return process.env.NODE_ENV===e.DEV}function l(e){if(typeof e!=`string`)throw TypeError(`Expected a string`);if(e.length>254)return!1;let t=e.split(`@`);if(t.length!==2)return!1;let[n,r]=t;return n.length===0||n.length>64||r.length===0||r.length>255?!1:!(!/^[a-zA-Z0-9_%+-]+(\.[a-zA-Z0-9_%+-]+)*$/.test(n)||!/^(?!.*\.\.)(?!-)[A-Za-z0-9-]{1,63}(?<!-)(\.[A-Za-z0-9-]{1,63}(?<!-))*\.[A-Za-z]{2,}$/.test(r))}function u(e){return e==null?!0:typeof e==`string`?e.trim().length===0:Array.isArray(e)?e.length===0:e instanceof Map||e instanceof Set?e.size===0:Object.prototype.toString.call(e)===`[object Object]`?Object.keys(e).length===0:!1}function d(e){return typeof e==`object`&&!!e&&Object.keys(e).length===0&&!a(e)}function f(e){return!e}function p(e){return/^[a-z0-9]+(-[a-z0-9]+)*$/.test(e)}function m(e){return/^[a-z]+$/.test(e)}function h(){return typeof process<`u`&&process.versions!==null&&process.versions.node!==null}function g(e){return typeof e==`object`&&!!e&&Object.keys(e).length>0&&!a(e)}function _(e){return e!=null&&typeof e==`string`}function v(e,t=!0){return _(e)?typeof e==`string`&&(t?e.trim().length>0:e.length>0):!1}function y(e){return!isNaN(Number(e))&&!isNaN(parseFloat(e))}function b(e){return i(e)&&typeof e==`object`&&!a(e)&&Object.getPrototypeOf(e)===Object.prototype}function x(e){return/^[A-Z][a-zA-Z0-9]*$/.test(e)}function S(){return process.env.NODE_ENV===e.PROD}function C(e){return/^[a-z0-9]+(_[a-z0-9]+)*$/.test(e)}function w(){return process.env.NODE_ENV===e.TEST}function T(e){return!!e}function E(e){return e==null}function D(e){return/^[A-Z]+$/.test(e)}function O(e){try{return new URL(e),!0}catch{return!1}}function k(e){return/^[A-Z]/.test(e)}export{t as endsWithPunctuation,n as hasWhitespace,r as isAlphabetic,a as isArray,o as isBrowser,s as isCamelCase,i as isDefined,c as isDev,l as isEmail,u as isEmpty,d as isEmptyObject,f as isFalsy,p as isKebabCase,m as isLowerCase,h as isNode,g as isNonEmptyObject,v as isNonEmptyString,y as isNumericString,b as isObject,x as isPascalCase,S as isProd,C as isSnakeCase,_ as isString,w as isTest,T as isTruthy,O as isURL,E as isUndefinedOrNull,D as isUpperCase,k as startsWithUppercase};
1
+ function e(e){return/[\p{P}]$/u.test(e)}function t(e){return/\s/.test(e)}function n(e){return/^[a-zA-Z]+$/.test(e)}function r(e){return e!=null}function i(e){return r(e)&&Array.isArray(e)}function a(e){return/^[a-z][a-zA-Z0-9]*$/.test(e)}function o(e){if(typeof e!=`string`)throw TypeError(`Expected a string`);if(e.length>254)return!1;let t=e.split(`@`);if(t.length!==2)return!1;let[n,r]=t;return n.length===0||n.length>64||r.length===0||r.length>255?!1:!(!/^[a-zA-Z0-9_%+-]+(\.[a-zA-Z0-9_%+-]+)*$/.test(n)||!/^(?!.*\.\.)(?!-)[A-Za-z0-9-]{1,63}(?<!-)(\.[A-Za-z0-9-]{1,63}(?<!-))*\.[A-Za-z]{2,}$/.test(r))}function s(e){return e==null?!0:typeof e==`string`?e.trim().length===0:Array.isArray(e)?e.length===0:e instanceof Map||e instanceof Set?e.size===0:Object.prototype.toString.call(e)===`[object Object]`?Object.keys(e).length===0:!1}function c(e){return typeof e==`object`&&!!e&&Object.keys(e).length===0&&!i(e)}function l(e){return!e}function u(e){return/^[a-z0-9]+(-[a-z0-9]+)*$/.test(e)}function d(e){return/^[a-z]+$/.test(e)}function f(e){return typeof e==`object`&&!!e&&Object.keys(e).length>0&&!i(e)}function p(e){return e!=null&&typeof e==`string`}function m(e,t=!0){return p(e)?typeof e==`string`&&(t?e.trim().length>0:e.length>0):!1}function h(e){return!isNaN(Number(e))&&!isNaN(parseFloat(e))}function g(e){return r(e)&&typeof e==`object`&&!i(e)&&Object.getPrototypeOf(e)===Object.prototype}function _(e){return/^[A-Z][a-zA-Z0-9]*$/.test(e)}function v(e){return/^[a-z0-9]+(_[a-z0-9]+)*$/.test(e)}function y(e){return!!e}function b(e){return e==null}function x(e){return/^[A-Z]+$/.test(e)}function S(e){try{return new URL(e),!0}catch{return!1}}function C(e){return/^[A-Z]/.test(e)}export{e as endsWithPunctuation,t as hasWhitespace,n as isAlphabetic,i as isArray,a as isCamelCase,r as isDefined,o as isEmail,s as isEmpty,c as isEmptyObject,l as isFalsy,u as isKebabCase,d as isLowerCase,f as isNonEmptyObject,m as isNonEmptyString,h as isNumericString,g as isObject,_ as isPascalCase,v as isSnakeCase,p as isString,y as isTruthy,S as isURL,b as isUndefinedOrNull,x as isUpperCase,C as startsWithUppercase};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@js-utils-kit/valid",
3
- "version": "1.3.0",
3
+ "version": "2.0.0",
4
4
  "description": "Validation utilities",
5
5
  "license": "MIT",
6
6
  "private": false,
@@ -36,13 +36,11 @@
36
36
  "types": "./dist/index.d.cts",
37
37
  "exports": {
38
38
  ".": {
39
- "require": "./dist/index.cjs",
40
- "import": "./dist/index.mjs"
39
+ "import": "./dist/index.mjs",
40
+ "require": "./dist/index.cjs"
41
41
  }
42
42
  },
43
- "dependencies": {
44
- "@js-utils-kit/types": "1.3.0"
45
- },
43
+ "dependencies": {},
46
44
  "scripts": {
47
45
  "build": "tsdown",
48
46
  "test": "vitest run"