shelving 1.155.0 → 1.156.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/package.json
CHANGED
package/schema/ChoiceSchema.d.ts
CHANGED
|
@@ -7,12 +7,14 @@ export type ChoiceOptions<K extends string> = {
|
|
|
7
7
|
export interface ChoiceSchemaOptions<K extends string> extends Omit<SchemaOptions, "value"> {
|
|
8
8
|
/** Specify correct options using a dictionary of entries. */
|
|
9
9
|
options: ChoiceOptions<K>;
|
|
10
|
+
/** Default option for the value. */
|
|
11
|
+
value?: K;
|
|
10
12
|
}
|
|
11
13
|
/** Choose from an allowed set of values. */
|
|
12
14
|
export declare class ChoiceSchema<K extends string> extends Schema<K> {
|
|
13
15
|
readonly value: string;
|
|
14
16
|
readonly options: ChoiceOptions<K>;
|
|
15
|
-
constructor({ options, ...rest }: ChoiceSchemaOptions<K>);
|
|
17
|
+
constructor({ options, value, ...rest }: ChoiceSchemaOptions<K>);
|
|
16
18
|
validate(unsafeValue?: unknown): K;
|
|
17
19
|
}
|
|
18
20
|
/** Choose from an allowed set of values. */
|
package/schema/ChoiceSchema.js
CHANGED
|
@@ -5,8 +5,8 @@ import { Schema } from "./Schema.js";
|
|
|
5
5
|
/** Choose from an allowed set of values. */
|
|
6
6
|
export class ChoiceSchema extends Schema {
|
|
7
7
|
options;
|
|
8
|
-
constructor({ options, ...rest }) {
|
|
9
|
-
super({ value
|
|
8
|
+
constructor({ options, value = requireFirst(getKeys(options)), ...rest }) {
|
|
9
|
+
super({ value, ...rest });
|
|
10
10
|
this.options = options;
|
|
11
11
|
}
|
|
12
12
|
validate(unsafeValue = this.value) {
|