shelving 1.244.0 → 1.244.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "shelving",
3
- "version": "1.244.0",
3
+ "version": "1.244.1",
4
4
  "author": "Dave Houlbrooke <dave@shax.com>",
5
5
  "repository": {
6
6
  "type": "git",
@@ -4,7 +4,7 @@ import { StringSchema, type StringSchemaOptions } from "./StringSchema.js";
4
4
  *
5
5
  * @see https://dhoulb.github.io/shelving/schema/ColorSchema/ColorSchemaOptions
6
6
  */
7
- export interface ColorSchemaOptions extends Omit<StringSchemaOptions, "type" | "min" | "max" | "match" | "rows"> {
7
+ export interface ColorSchemaOptions extends Omit<StringSchemaOptions, "min" | "match" | "rows"> {
8
8
  }
9
9
  /**
10
10
  * Schema that defines a valid color hex string, e.g. `#00CCFF`
@@ -19,12 +19,14 @@ export declare class ColorSchema extends StringSchema {
19
19
  /**
20
20
  * Create a new `ColorSchema`.
21
21
  *
22
- * @param options Options for the schema (inherits `StringSchema` options except `type`, `min`, `max`, `match`, and `rows`, which are fixed for hex colors).
22
+ * @param options Options for the schema (inherits `StringSchema` options except `min`, `match`, and `rows`, which are fixed for hex colors).
23
23
  * @param options.one Singular noun describing one value, used in error messages (defaults to `"color"`).
24
24
  * @param options.title Title of the schema, e.g. for a corresponding field (defaults to `"Color"`).
25
25
  * @param options.value Default hex value used when the input is `undefined` (defaults to `"#000000"`).
26
+ * @param options.input HTML `<input />` `type=""` hint (defaults to `"color"`).
27
+ * @param options.max Maximum allowed character length (defaults to `7`).
26
28
  */
27
- constructor({ one, title, value, ...options }: ColorSchemaOptions);
29
+ constructor({ one, title, value, input, max, ...options }: ColorSchemaOptions);
28
30
  /**
29
31
  * Sanitize the string into a `#RRGGBB` hex color.
30
32
  *
@@ -15,20 +15,22 @@ export class ColorSchema extends StringSchema {
15
15
  /**
16
16
  * Create a new `ColorSchema`.
17
17
  *
18
- * @param options Options for the schema (inherits `StringSchema` options except `type`, `min`, `max`, `match`, and `rows`, which are fixed for hex colors).
18
+ * @param options Options for the schema (inherits `StringSchema` options except `min`, `match`, and `rows`, which are fixed for hex colors).
19
19
  * @param options.one Singular noun describing one value, used in error messages (defaults to `"color"`).
20
20
  * @param options.title Title of the schema, e.g. for a corresponding field (defaults to `"Color"`).
21
21
  * @param options.value Default hex value used when the input is `undefined` (defaults to `"#000000"`).
22
+ * @param options.input HTML `<input />` `type=""` hint (defaults to `"color"`).
23
+ * @param options.max Maximum allowed character length (defaults to `7`).
22
24
  */
23
- constructor({ one = "color", title = "Color", value = "#000000", ...options }) {
25
+ constructor({ one = "color", title = "Color", value = "#000000", input = "color", max = 7, ...options }) {
24
26
  super({
25
27
  one,
26
28
  title,
27
29
  value,
28
30
  ...options,
29
- input: "color",
31
+ input,
32
+ max,
30
33
  min: 1,
31
- max: 7,
32
34
  rows: 1,
33
35
  match: COLOR_REGEXP,
34
36
  });
@@ -9,7 +9,7 @@ import { StringSchema } from "./StringSchema.js";
9
9
  *
10
10
  * @see https://dhoulb.github.io/shelving/schema/CurrencyCodeSchema/CurrencyCodeSchemaOptions
11
11
  */
12
- export interface CurrencyCodeSchemaOptions extends Omit<StringSchemaOptions, "input" | "min" | "max" | "match" | "rows"> {
12
+ export interface CurrencyCodeSchemaOptions extends Omit<StringSchemaOptions, "min" | "match" | "rows"> {
13
13
  currencies?: ImmutableArray<CurrencyCode>;
14
14
  }
15
15
  /**
@@ -32,11 +32,11 @@ export declare class CurrencyCodeSchema extends StringSchema {
32
32
  /**
33
33
  * Create a new `CurrencyCodeSchema`.
34
34
  *
35
- * @param options Options for the schema (`currencies`, plus base `StringSchemaOptions` except `input`/`min`/`max`/`match`/`rows`).
35
+ * @param options Options for the schema (`currencies`, plus base `StringSchemaOptions` except `min`/`match`/`rows`).
36
36
  * @example new CurrencyCodeSchema({ currencies: ["GBP", "USD"] })
37
37
  * @see https://dhoulb.github.io/shelving/schema/CurrencyCodeSchema/CurrencyCodeSchema
38
38
  */
39
- constructor({ one, title, currencies, ...options }: CurrencyCodeSchemaOptions);
39
+ constructor({ one, title, currencies, max, ...options }: CurrencyCodeSchemaOptions);
40
40
  /**
41
41
  * Sanitize an input string down to uppercase `A-Z` letters.
42
42
  *
@@ -21,17 +21,17 @@ export class CurrencyCodeSchema extends StringSchema {
21
21
  /**
22
22
  * Create a new `CurrencyCodeSchema`.
23
23
  *
24
- * @param options Options for the schema (`currencies`, plus base `StringSchemaOptions` except `input`/`min`/`max`/`match`/`rows`).
24
+ * @param options Options for the schema (`currencies`, plus base `StringSchemaOptions` except `min`/`match`/`rows`).
25
25
  * @example new CurrencyCodeSchema({ currencies: ["GBP", "USD"] })
26
26
  * @see https://dhoulb.github.io/shelving/schema/CurrencyCodeSchema/CurrencyCodeSchema
27
27
  */
28
- constructor({ one = "currency", title = "Currency", currencies = CURRENCY_CODES, ...options }) {
28
+ constructor({ one = "currency", title = "Currency", currencies = CURRENCY_CODES, max = 3, ...options }) {
29
29
  super({
30
30
  one,
31
31
  title,
32
32
  ...options,
33
+ max, // Valid currency code is 3 uppercase letters.
33
34
  min: 3,
34
- max: 3, // Valid currency code is 3 uppercase letters.
35
35
  rows: 1,
36
36
  case: "upper",
37
37
  match: /^[A-Z]{3}$/, // Valid currency code is 3 uppercase letters.
@@ -1,5 +1,12 @@
1
1
  import type { StringSchemaOptions } from "./StringSchema.js";
2
2
  import { StringSchema } from "./StringSchema.js";
3
+ /**
4
+ * Options for an `EmailSchema`.
5
+ *
6
+ * @see https://dhoulb.github.io/shelving/schema/EmailSchema/EmailSchemaOptions
7
+ */
8
+ export interface EmailSchemaOptions extends Omit<StringSchemaOptions, "min" | "match" | "rows"> {
9
+ }
3
10
  /**
4
11
  * Schema that defines a valid email address.
5
12
  *
@@ -24,11 +31,13 @@ export declare class EmailSchema extends StringSchema {
24
31
  /**
25
32
  * Create a new `EmailSchema`.
26
33
  *
27
- * @param options Options for the schema (inherits `StringSchema` options except `type`, `min`, `max`, `match`, and `rows`, which are fixed for emails).
34
+ * @param options Options for the schema (inherits `StringSchema` options except `min`, `match`, and `rows`, which are fixed for emails).
28
35
  * @param options.one Singular noun describing one value, used in error messages (defaults to `"email address"`).
29
36
  * @param options.title Title of the schema, e.g. for a corresponding field (defaults to `"Email"`).
37
+ * @param options.input HTML `<input />` `type=""` hint (defaults to `"email"`).
38
+ * @param options.max Maximum allowed character length (defaults to `254`).
30
39
  */
31
- constructor({ one, title, ...options }: Omit<StringSchemaOptions, "type" | "min" | "max" | "match" | "rows">);
40
+ constructor({ one, title, input, max, ...options }: EmailSchemaOptions);
32
41
  /**
33
42
  * Sanitize the string into a valid email address.
34
43
  *
@@ -26,18 +26,20 @@ export class EmailSchema extends StringSchema {
26
26
  /**
27
27
  * Create a new `EmailSchema`.
28
28
  *
29
- * @param options Options for the schema (inherits `StringSchema` options except `type`, `min`, `max`, `match`, and `rows`, which are fixed for emails).
29
+ * @param options Options for the schema (inherits `StringSchema` options except `min`, `match`, and `rows`, which are fixed for emails).
30
30
  * @param options.one Singular noun describing one value, used in error messages (defaults to `"email address"`).
31
31
  * @param options.title Title of the schema, e.g. for a corresponding field (defaults to `"Email"`).
32
+ * @param options.input HTML `<input />` `type=""` hint (defaults to `"email"`).
33
+ * @param options.max Maximum allowed character length (defaults to `254`).
32
34
  */
33
- constructor({ one = "email address", title = "Email", ...options }) {
35
+ constructor({ one = "email address", title = "Email", input = "email", max = 254, ...options }) {
34
36
  super({
35
37
  one,
36
38
  title,
37
39
  ...options,
38
- input: "email",
40
+ input,
41
+ max,
39
42
  min: 1,
40
- max: 254,
41
43
  rows: 1,
42
44
  match: R_MATCH,
43
45
  });
@@ -1,15 +1,8 @@
1
1
  import { StringSchema, type StringSchemaOptions } from "./StringSchema.js";
2
- /**
3
- * Options for a `PasswordSchema`.
4
- *
5
- * @see https://dhoulb.github.io/shelving/schema/PasswordSchema/PasswordSchemaOptions
6
- */
7
- export interface PasswordSchemaOptions extends Omit<StringSchemaOptions, "input"> {
8
- }
9
2
  /**
10
3
  * Schema that defines a valid password string.
11
4
  *
12
- * - Forces the `<input />` hint to `"password"` for downstream UIs.
5
+ * - Defaults the `<input />` hint to `"password"`, but a caller can override it (e.g. `"text"` for a show-password toggle).
13
6
  * - Never formats the value for display (`format()` always returns `""`).
14
7
  *
15
8
  * @example new PasswordSchema({}).validate("hunter2"); // Returns "hunter2"
@@ -19,12 +12,13 @@ export declare class PasswordSchema extends StringSchema {
19
12
  /**
20
13
  * Create a new `PasswordSchema`.
21
14
  *
22
- * @param options Options for the schema (inherits `StringSchema` options except `input`, which is fixed to `"password"`).
15
+ * @param options Options for the schema (inherits all `StringSchema` options).
23
16
  * @param options.one Singular noun describing one value, used in error messages (defaults to `"password"`).
24
17
  * @param options.title Title of the schema, e.g. for a corresponding field (defaults to `"Password"`).
25
18
  * @param options.min Minimum allowed character length (defaults to `6`).
19
+ * @param options.input HTML `<input />` `type=""` hint (defaults to `"password"`).
26
20
  */
27
- constructor({ one, title, min, ...options }?: PasswordSchemaOptions);
21
+ constructor({ one, title, min, input, ...options }?: StringSchemaOptions);
28
22
  /**
29
23
  * Format a password value for display (always returns `""`).
30
24
  *
@@ -37,9 +31,9 @@ export declare class PasswordSchema extends StringSchema {
37
31
  format(): string;
38
32
  }
39
33
  /**
40
- * Sugar instance of [`StringSchema`](/schema/StringSchema) for a password string. Equivalent to `new StringSchema({})`.
34
+ * Sugar instance of [`PasswordSchema`](/schema/PasswordSchema) for a password string. Equivalent to `new PasswordSchema({})`.
41
35
  *
42
36
  * @example PASSWORD.validate("hunter2"); // Returns "hunter2"
43
37
  * @see https://dhoulb.github.io/shelving/schema/PasswordSchema/PASSWORD
44
38
  */
45
- export declare const PASSWORD: StringSchema;
39
+ export declare const PASSWORD: PasswordSchema;
@@ -2,7 +2,7 @@ import { StringSchema } from "./StringSchema.js";
2
2
  /**
3
3
  * Schema that defines a valid password string.
4
4
  *
5
- * - Forces the `<input />` hint to `"password"` for downstream UIs.
5
+ * - Defaults the `<input />` hint to `"password"`, but a caller can override it (e.g. `"text"` for a show-password toggle).
6
6
  * - Never formats the value for display (`format()` always returns `""`).
7
7
  *
8
8
  * @example new PasswordSchema({}).validate("hunter2"); // Returns "hunter2"
@@ -12,13 +12,14 @@ export class PasswordSchema extends StringSchema {
12
12
  /**
13
13
  * Create a new `PasswordSchema`.
14
14
  *
15
- * @param options Options for the schema (inherits `StringSchema` options except `input`, which is fixed to `"password"`).
15
+ * @param options Options for the schema (inherits all `StringSchema` options).
16
16
  * @param options.one Singular noun describing one value, used in error messages (defaults to `"password"`).
17
17
  * @param options.title Title of the schema, e.g. for a corresponding field (defaults to `"Password"`).
18
18
  * @param options.min Minimum allowed character length (defaults to `6`).
19
+ * @param options.input HTML `<input />` `type=""` hint (defaults to `"password"`).
19
20
  */
20
- constructor({ one = "password", title = "Password", min = 6, ...options } = {}) {
21
- super({ one, title, min, ...options, input: "password" });
21
+ constructor({ one = "password", title = "Password", min = 6, input = "password", ...options } = {}) {
22
+ super({ one, title, min, input, ...options });
22
23
  }
23
24
  /**
24
25
  * Format a password value for display (always returns `""`).
@@ -34,9 +35,9 @@ export class PasswordSchema extends StringSchema {
34
35
  }
35
36
  }
36
37
  /**
37
- * Sugar instance of [`StringSchema`](/schema/StringSchema) for a password string. Equivalent to `new StringSchema({})`.
38
+ * Sugar instance of [`PasswordSchema`](/schema/PasswordSchema) for a password string. Equivalent to `new PasswordSchema({})`.
38
39
  *
39
40
  * @example PASSWORD.validate("hunter2"); // Returns "hunter2"
40
41
  * @see https://dhoulb.github.io/shelving/schema/PasswordSchema/PASSWORD
41
42
  */
42
- export const PASSWORD = new StringSchema({});
43
+ export const PASSWORD = new PasswordSchema({});
@@ -5,7 +5,7 @@ import { StringSchema } from "./StringSchema.js";
5
5
  *
6
6
  * @see https://dhoulb.github.io/shelving/schema/PhoneSchema/PhoneSchemaOptions
7
7
  */
8
- export interface PhoneSchemaOptions extends Omit<StringSchemaOptions, "input" | "min" | "max" | "match" | "rows"> {
8
+ export interface PhoneSchemaOptions extends Omit<StringSchemaOptions, "min" | "match" | "rows"> {
9
9
  }
10
10
  /**
11
11
  * Schema that defines a valid phone number.
@@ -20,11 +20,13 @@ export declare class PhoneSchema extends StringSchema {
20
20
  /**
21
21
  * Create a new `PhoneSchema`.
22
22
  *
23
- * @param options Options for the schema (inherits `StringSchema` options except `input`, `min`, `max`, `match`, and `rows`, which are fixed for phone numbers).
23
+ * @param options Options for the schema (inherits `StringSchema` options except `min`, `match`, and `rows`, which are fixed for phone numbers).
24
24
  * @param options.one Singular noun describing one value, used in error messages (defaults to `"phone number"`).
25
25
  * @param options.title Title of the schema, e.g. for a corresponding field (defaults to `"Phone"`).
26
+ * @param options.input HTML `<input />` `type=""` hint (defaults to `"tel"`).
27
+ * @param options.max Maximum allowed character length (defaults to `16`).
26
28
  */
27
- constructor({ one, title, ...options }: PhoneSchemaOptions);
29
+ constructor({ one, title, input, max, ...options }: PhoneSchemaOptions);
28
30
  /**
29
31
  * Sanitize the string into a valid E.164 phone number.
30
32
  *
@@ -13,19 +13,21 @@ export class PhoneSchema extends StringSchema {
13
13
  /**
14
14
  * Create a new `PhoneSchema`.
15
15
  *
16
- * @param options Options for the schema (inherits `StringSchema` options except `input`, `min`, `max`, `match`, and `rows`, which are fixed for phone numbers).
16
+ * @param options Options for the schema (inherits `StringSchema` options except `min`, `match`, and `rows`, which are fixed for phone numbers).
17
17
  * @param options.one Singular noun describing one value, used in error messages (defaults to `"phone number"`).
18
18
  * @param options.title Title of the schema, e.g. for a corresponding field (defaults to `"Phone"`).
19
+ * @param options.input HTML `<input />` `type=""` hint (defaults to `"tel"`).
20
+ * @param options.max Maximum allowed character length (defaults to `16`).
19
21
  */
20
- constructor({ one = "phone number", title = "Phone", ...options }) {
22
+ constructor({ one = "phone number", title = "Phone", input = "tel", max = 16, ...options }) {
21
23
  super({
22
24
  one,
23
25
  title,
24
26
  ...options,
25
- input: "tel",
26
- min: 1,
27
+ input,
27
28
  // Valid phone number is 16 digits or fewer (15 numerals with a leading `+` plus).
28
- max: 16,
29
+ max,
30
+ min: 1,
29
31
  rows: 1,
30
32
  // Valid phone number is max 16 digits made up of:
31
33
  // - Country code (`+` plus character and 1-3 digits, e.g. `+44` or `+1`).
@@ -1,4 +1,11 @@
1
1
  import { StringSchema, type StringSchemaOptions } from "./StringSchema.js";
2
+ /**
3
+ * Options for a `SlugSchema`.
4
+ *
5
+ * @see https://dhoulb.github.io/shelving/schema/SlugSchema/SlugSchemaOptions
6
+ */
7
+ export interface SlugSchemaOptions extends Omit<StringSchemaOptions, "min" | "rows"> {
8
+ }
2
9
  /**
3
10
  * Schema that defines a valid slug, e.g. `this-is-a-slug`.
4
11
  *
@@ -17,7 +24,7 @@ export declare class SlugSchema extends StringSchema {
17
24
  *
18
25
  * @param options Options for the schema (inherited string options like `one`, `title`, `value`).
19
26
  */
20
- constructor(options: Omit<StringSchemaOptions, "min" | "max" | "rows">);
27
+ constructor({ max, ...options }: SlugSchemaOptions);
21
28
  /**
22
29
  * Sanitize a string before validation by converting it into a slug.
23
30
  *
@@ -19,11 +19,11 @@ export class SlugSchema extends StringSchema {
19
19
  *
20
20
  * @param options Options for the schema (inherited string options like `one`, `title`, `value`).
21
21
  */
22
- constructor(options) {
22
+ constructor({ max = 32, ...options }) {
23
23
  super({
24
24
  ...options,
25
+ max,
25
26
  min: 1,
26
- max: 32,
27
27
  rows: 1,
28
28
  });
29
29
  }
@@ -8,7 +8,7 @@ import { StringSchema } from "./StringSchema.js";
8
8
  *
9
9
  * @see https://dhoulb.github.io/shelving/schema/URISchema/URISchemaOptions
10
10
  */
11
- export interface URISchemaOptions extends Omit<StringSchemaOptions, "input" | "min" | "max" | "rows"> {
11
+ export interface URISchemaOptions extends Omit<StringSchemaOptions, "min" | "rows"> {
12
12
  readonly schemes?: URISchemes | undefined;
13
13
  }
14
14
  /**
@@ -28,9 +28,11 @@ export declare class URISchema extends StringSchema {
28
28
  /**
29
29
  * Create a new `URISchema`.
30
30
  *
31
- * @param options Options for the schema (`schemes`, plus inherited string options like `one`, `title`, `value`).
31
+ * @param options Options for the schema (`schemes`, plus inherited string options like `one`, `title`, `value`, `input`, `max`).
32
+ * @param options.input HTML `<input />` `type=""` hint (defaults to `"url"`).
33
+ * @param options.max Maximum allowed character length (defaults to `512`).
32
34
  */
33
- constructor({ one, title, schemes, ...options }: URISchemaOptions);
35
+ constructor({ one, title, schemes, input, max, ...options }: URISchemaOptions);
34
36
  /**
35
37
  * Validate an unknown input value and return a normalised absolute URI string.
36
38
  *
@@ -20,16 +20,18 @@ export class URISchema extends StringSchema {
20
20
  /**
21
21
  * Create a new `URISchema`.
22
22
  *
23
- * @param options Options for the schema (`schemes`, plus inherited string options like `one`, `title`, `value`).
23
+ * @param options Options for the schema (`schemes`, plus inherited string options like `one`, `title`, `value`, `input`, `max`).
24
+ * @param options.input HTML `<input />` `type=""` hint (defaults to `"url"`).
25
+ * @param options.max Maximum allowed character length (defaults to `512`).
24
26
  */
25
- constructor({ one = "URI", title = "URI", schemes = HTTP_SCHEMES, ...options }) {
27
+ constructor({ one = "URI", title = "URI", schemes = HTTP_SCHEMES, input = "url", max = 512, ...options }) {
26
28
  super({
27
29
  one,
28
30
  title,
29
31
  ...options,
30
- input: "url",
32
+ input,
33
+ max,
31
34
  min: 1,
32
- max: 512,
33
35
  rows: 1,
34
36
  });
35
37
  this.schemes = schemes;
@@ -10,7 +10,7 @@ import { StringSchema } from "./StringSchema.js";
10
10
  *
11
11
  * @see https://dhoulb.github.io/shelving/schema/URLSchema/URLSchemaOptions
12
12
  */
13
- export interface URLSchemaOptions extends Omit<StringSchemaOptions, "input" | "min" | "max" | "rows"> {
13
+ export interface URLSchemaOptions extends Omit<StringSchemaOptions, "min" | "rows"> {
14
14
  readonly base?: URL | URLString | undefined;
15
15
  readonly schemes?: URISchemes | undefined;
16
16
  }
@@ -33,9 +33,11 @@ export declare class URLSchema extends StringSchema {
33
33
  /**
34
34
  * Create a new `URLSchema`.
35
35
  *
36
- * @param options Options for the schema (`base`, `schemes`, plus inherited string options like `one`, `title`, `value`).
36
+ * @param options Options for the schema (`base`, `schemes`, plus inherited string options like `one`, `title`, `value`, `input`, `max`).
37
+ * @param options.input HTML `<input />` `type=""` hint (defaults to `"url"`).
38
+ * @param options.max Maximum allowed character length (defaults to `512`).
37
39
  */
38
- constructor({ one, title, base, schemes, ...options }: URLSchemaOptions);
40
+ constructor({ one, title, base, schemes, input, max, ...options }: URLSchemaOptions);
39
41
  /**
40
42
  * Validate an unknown input value and return a normalised absolute URL string.
41
43
  *
@@ -23,16 +23,18 @@ export class URLSchema extends StringSchema {
23
23
  /**
24
24
  * Create a new `URLSchema`.
25
25
  *
26
- * @param options Options for the schema (`base`, `schemes`, plus inherited string options like `one`, `title`, `value`).
26
+ * @param options Options for the schema (`base`, `schemes`, plus inherited string options like `one`, `title`, `value`, `input`, `max`).
27
+ * @param options.input HTML `<input />` `type=""` hint (defaults to `"url"`).
28
+ * @param options.max Maximum allowed character length (defaults to `512`).
27
29
  */
28
- constructor({ one = "URL", title = "URL", base, schemes = HTTP_SCHEMES, ...options }) {
30
+ constructor({ one = "URL", title = "URL", base, schemes = HTTP_SCHEMES, input = "url", max = 512, ...options }) {
29
31
  super({
30
32
  one,
31
33
  title,
32
34
  ...options,
33
- input: "url",
35
+ input,
36
+ max,
34
37
  min: 1,
35
- max: 512,
36
38
  rows: 1,
37
39
  });
38
40
  this.base = getURL(base)?.href;
@@ -1,4 +1,11 @@
1
1
  import { StringSchema, type StringSchemaOptions } from "./StringSchema.js";
2
+ /**
3
+ * Options for a `UUIDSchema`.
4
+ *
5
+ * @see https://dhoulb.github.io/shelving/schema/UUIDSchema/UUIDSchemaOptions
6
+ */
7
+ export interface UUIDSchemaOptions extends Omit<StringSchemaOptions, "min" | "match" | "rows"> {
8
+ }
2
9
  /**
3
10
  * Schema that defines a valid UUID string (versions 1-5). Defaults to any-version validation.
4
11
  *
@@ -14,9 +21,10 @@ export declare class UUIDSchema extends StringSchema {
14
21
  /**
15
22
  * Create a new `UUIDSchema`.
16
23
  *
17
- * @param options Options for the schema (inherited string options like `one`, `title`, `value`).
24
+ * @param options Options for the schema (inherited string options like `one`, `title`, `value`, `input`, `max`).
25
+ * @param options.max Maximum allowed character length (defaults to `36`).
18
26
  */
19
- constructor({ one, title, ...rest }?: Omit<StringSchemaOptions, "input" | "min" | "max" | "match" | "rows">);
27
+ constructor({ one, title, max, ...rest }?: UUIDSchemaOptions);
20
28
  /**
21
29
  * Sanitize a string before validation by normalising it into a canonical UUID.
22
30
  *
@@ -16,15 +16,16 @@ export class UUIDSchema extends StringSchema {
16
16
  /**
17
17
  * Create a new `UUIDSchema`.
18
18
  *
19
- * @param options Options for the schema (inherited string options like `one`, `title`, `value`).
19
+ * @param options Options for the schema (inherited string options like `one`, `title`, `value`, `input`, `max`).
20
+ * @param options.max Maximum allowed character length (defaults to `36`).
20
21
  */
21
- constructor({ one = "UUID", title = "UUID", ...rest } = {}) {
22
+ constructor({ one = "UUID", title = "UUID", max = 36, ...rest } = {}) {
22
23
  super({
23
24
  one,
24
25
  title,
25
26
  ...rest,
27
+ max, // 36 chars including hyphens (which get stripped by sanitize for appearances).
26
28
  min: 32,
27
- max: 36, // 36 chars including hyphens (which get stripped by sanitize for appearances).
28
29
  rows: 1,
29
30
  });
30
31
  }