@qui-cli/validators 3.0.1 → 3.0.3

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,20 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [commit-and-tag-version](https://github.com/absolute-version/commit-and-tag-version) for commit guidelines.
4
4
 
5
+ ## [3.0.3](https://github.com/battis/qui-cli/compare/validators/3.0.2...validators/3.0.3) (2026-01-02)
6
+
7
+
8
+ ### Bug Fixes
9
+
10
+ * normalize peer dependencies ([cdd81b7](https://github.com/battis/qui-cli/commit/cdd81b7c4bea7c769021ff58177750c5a1369f76))
11
+
12
+ ## [3.0.2](https://github.com/battis/qui-cli/compare/validators/3.0.1...validators/3.0.2) (2025-11-07)
13
+
14
+
15
+ ### Bug Fixes
16
+
17
+ * remove unnecessary plugin dependency ([ac4be0b](https://github.com/battis/qui-cli/commit/ac4be0b7d92240beecc673cbfafa4502b439663a))
18
+
5
19
  ## [3.0.1](https://github.com/battis/qui-cli/compare/validators/3.0.0...validators/3.0.1) (2025-08-04)
6
20
 
7
21
 
@@ -1,21 +1,38 @@
1
1
  export type Validator = (value?: string) => boolean | string;
2
- export declare const name = "validators";
2
+ /** Non-empty string */
3
3
  export declare function notEmpty(value?: string): true | "May not be empty";
4
+ /** A string of at least `minLength` characters */
4
5
  export declare function minLength(minLength: number): Validator;
6
+ /** A string of no more than `maxLength` charaters */
5
7
  export declare function maxLength(maxLength: number): Validator;
8
+ /** A string that is a valid file path */
6
9
  export declare function isPath(value?: string): true | "Must be a valid path";
10
+ /** A string that matches the regular expression `pattern` */
7
11
  export declare function match(pattern: RegExp): Validator;
12
+ /** A {@link Validator} that validates that a string is between `min` and `max` characters, inclusive */
8
13
  export declare function lengthBetween(min: number, max: number): Validator;
14
+ /** A string that is a valid email address */
9
15
  export declare function email(): Validator;
16
+ /** A string that is a valid crontab schedule */
10
17
  export declare function cron(value?: string): any;
18
+ /** A {@link Validator} that validates a string as a valid hostname */
11
19
  export declare function isHostname({ subdomain, wildcard, allowUnicode, topLevel, localhost, ipAddress, allowed }: {
20
+ /** require a subdomain */
12
21
  subdomain?: boolean;
22
+ /** allow wildcards */
13
23
  wildcard?: boolean;
24
+ /** allow Unicode characters */
14
25
  allowUnicode?: boolean;
26
+ /** require a top-level domain name */
15
27
  topLevel?: boolean;
28
+ /** allow localhost */
16
29
  localhost?: boolean;
30
+ /** allow UP address */
17
31
  ipAddress?: boolean;
32
+ /** specific allowed hostnames */
18
33
  allowed?: string[];
19
34
  }): Validator;
35
+ /** A {@link Validator} that validates a string as a valid file path relative to `root` to a file that exists */
20
36
  export declare function pathExists(root?: string): Validator;
37
+ /** A {@link Validator} that combines other Validators */
21
38
  export declare function combine(...validators: Validator[]): Validator;
@@ -5,41 +5,49 @@ import emailValidator from 'email-validator';
5
5
  import pathValidator from 'is-valid-path';
6
6
  import fs from 'node:fs';
7
7
  import path from 'node:path';
8
- export const name = 'validators';
8
+ /** Non-empty string */
9
9
  export function notEmpty(value) {
10
10
  return (!!value && value.length > 0) || 'May not be empty';
11
11
  }
12
+ /** A string of at least `minLength` characters */
12
13
  export function minLength(minLength) {
13
14
  return (value) => (!!value && value.length >= minLength) ||
14
15
  `Must be at least ${minLength} characters`;
15
16
  }
17
+ /** A string of no more than `maxLength` charaters */
16
18
  export function maxLength(maxLength) {
17
19
  return (value) => (!!value && value.length <= maxLength) ||
18
20
  `Must be no more than ${maxLength} characters`;
19
21
  }
22
+ /** A string that is a valid file path */
20
23
  export function isPath(value) {
21
24
  return ((notEmpty(value) === true && pathValidator(value)) || 'Must be a valid path');
22
25
  }
26
+ /** A string that matches the regular expression `pattern` */
23
27
  export function match(pattern) {
24
28
  return (value) => (!!value && pattern.test(value)) ||
25
29
  `Must match pattern /${pattern.toString()}/`;
26
30
  }
31
+ /** A {@link Validator} that validates that a string is between `min` and `max` characters, inclusive */
27
32
  export function lengthBetween(min, max) {
28
33
  return (value) => (minLength(min)(value) === true && maxLength(max)(value) === true) ||
29
34
  `Must be between ${min} && ${max} characters`;
30
35
  }
36
+ /** A string that is a valid email address */
31
37
  export function email() {
32
38
  return (value) => (notEmpty(value) === true && emailValidator.validate(value || '')) ||
33
39
  'Must be valid email address';
34
40
  }
41
+ /** A string that is a valid crontab schedule */
35
42
  export function cron(value) {
36
43
  return (
37
44
  // FIXME cronValidator callable
38
45
  // Issue URL: https://github.com/battis/qui-cli/issues/27
39
- // @ts-ignore
46
+ // @ts-expect-error 2349 cronValidator typing
40
47
  (notEmpty(value) === true && cronValidator(value || '').isValid()) ||
41
48
  'Must be valid cron schedule');
42
49
  }
50
+ /** A {@link Validator} that validates a string as a valid hostname */
43
51
  export function isHostname({ subdomain = false, wildcard = false, allowUnicode = false, topLevel = false, localhost = true, ipAddress = true, allowed = [] }) {
44
52
  return (value) => {
45
53
  let domain;
@@ -59,6 +67,7 @@ export function isHostname({ subdomain = false, wildcard = false, allowUnicode =
59
67
  `Must be a valid hostname`);
60
68
  };
61
69
  }
70
+ /** A {@link Validator} that validates a string as a valid file path relative to `root` to a file that exists */
62
71
  export function pathExists(root = Root.path()) {
63
72
  return (value) => {
64
73
  const possiblePath = path.resolve(root, value || '');
@@ -66,6 +75,7 @@ export function pathExists(root = Root.path()) {
66
75
  `${possiblePath} does not exist`);
67
76
  };
68
77
  }
78
+ /** A {@link Validator} that combines other Validators */
69
79
  export function combine(...validators) {
70
80
  return (value) => validators.reduce((valid, validator) => {
71
81
  if (valid === true) {
package/dist/index.d.ts CHANGED
@@ -1,2 +1 @@
1
- import * as Validators from './Validators.js';
2
- export { Validators };
1
+ export * as Validators from './Validators.js';
package/dist/index.js CHANGED
@@ -1,4 +1 @@
1
- import { register } from '@qui-cli/plugin';
2
- import * as Validators from './Validators.js';
3
- await register(Validators);
4
- export { Validators };
1
+ export * as Validators from './Validators.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qui-cli/validators",
3
- "version": "3.0.1",
3
+ "version": "3.0.3",
4
4
  "description": "@qui-cli Plugin: Input validators",
5
5
  "homepage": "https://github.com/battis/qui-cli/tree/main/packages/validators#readme",
6
6
  "repository": {
@@ -18,24 +18,22 @@
18
18
  "types": "./dist/index.d.ts",
19
19
  "dependencies": {
20
20
  "@tahul/is-valid-domain": "^1.0.5",
21
- "cron-validate": "^1.5.2",
21
+ "cron-validate": "^1.5.3",
22
22
  "email-validator": "^2.0.4",
23
23
  "is-valid-path": "^0.1.1"
24
24
  },
25
25
  "devDependencies": {
26
- "@tsconfig/node20": "^20.1.6",
26
+ "@tsconfig/node20": "^20.1.8",
27
27
  "@types/is-valid-path": "^0.1.2",
28
- "@types/node": "^24.1.0",
29
- "commit-and-tag-version": "^12.5.2",
28
+ "@types/node": "^24.10.4",
29
+ "commit-and-tag-version": "^12.6.1",
30
30
  "del-cli": "^6.0.0",
31
31
  "npm-run-all": "^4.1.5",
32
- "typescript": "^5.9.2",
33
- "@qui-cli/root": "3.0.1",
34
- "@qui-cli/plugin": "3.0.0"
32
+ "typescript": "^5.9.3",
33
+ "@qui-cli/root": "3.0.6"
35
34
  },
36
35
  "peerDependencies": {
37
- "@qui-cli/plugin": "3.x",
38
- "@qui-cli/root": "3.x"
36
+ "@qui-cli/root": ">=3"
39
37
  },
40
38
  "target": "node",
41
39
  "scripts": {