shelving 1.158.3 → 1.159.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/ArraySchema.d.ts
CHANGED
|
@@ -39,7 +39,7 @@ export interface ArraySchemaOptions<T> extends SchemaOptions {
|
|
|
39
39
|
* schema.validate(["a", null], schema); // Throws Invalids({ "1": Invalid('Must be a string') });
|
|
40
40
|
*/
|
|
41
41
|
export declare class ArraySchema<T> extends Schema<ImmutableArray<T>> {
|
|
42
|
-
readonly value: ImmutableArray
|
|
42
|
+
readonly value: ImmutableArray<T>;
|
|
43
43
|
readonly one: string;
|
|
44
44
|
readonly many: string;
|
|
45
45
|
readonly items: Schema<T>;
|
package/schema/DataSchema.d.ts
CHANGED
|
@@ -11,9 +11,9 @@ export interface DataSchemaOptions<T extends Data> extends SchemaOptions {
|
|
|
11
11
|
}
|
|
12
12
|
/** Validate a data object. */
|
|
13
13
|
export declare class DataSchema<T extends Data> extends Schema<unknown> {
|
|
14
|
-
readonly value:
|
|
14
|
+
readonly value: T;
|
|
15
15
|
readonly props: Schemas<T>;
|
|
16
|
-
constructor({ props, title, value, ...options }: DataSchemaOptions<T>);
|
|
16
|
+
constructor({ props, title, value: partialValue, ...options }: DataSchemaOptions<T>);
|
|
17
17
|
validate(unsafeValue?: unknown): T;
|
|
18
18
|
}
|
|
19
19
|
/** Set of named data schemas. */
|
package/schema/DataSchema.js
CHANGED
|
@@ -8,7 +8,9 @@ import { Schema } from "./Schema.js";
|
|
|
8
8
|
/** Validate a data object. */
|
|
9
9
|
export class DataSchema extends Schema {
|
|
10
10
|
props;
|
|
11
|
-
constructor({ props, title = "Data", value
|
|
11
|
+
constructor({ props, title = "Data", value: partialValue, ...options }) {
|
|
12
|
+
// Build default value from props and partial value.
|
|
13
|
+
const value = { ...mapProps(props, _getSchemaValue), ...partialValue };
|
|
12
14
|
super({ title, value, ...options });
|
|
13
15
|
this.props = props;
|
|
14
16
|
}
|
|
@@ -18,6 +20,9 @@ export class DataSchema extends Schema {
|
|
|
18
20
|
return validateData(unsafeValue, this.props);
|
|
19
21
|
}
|
|
20
22
|
}
|
|
23
|
+
function _getSchemaValue([, { value }]) {
|
|
24
|
+
return value;
|
|
25
|
+
}
|
|
21
26
|
/** Create a `DataSchema` for a set of properties. */
|
|
22
27
|
export const DATA = (props) => new DataSchema({ props });
|
|
23
28
|
/** Valid data object with specifed properties, or `null` */
|
|
@@ -12,7 +12,7 @@ export interface DictionarySchemaOptions<T> extends SchemaOptions {
|
|
|
12
12
|
}
|
|
13
13
|
/** Validate a dictionary object (whose props are all the same with string keys). */
|
|
14
14
|
export declare class DictionarySchema<T> extends Schema<ImmutableDictionary<T>> {
|
|
15
|
-
readonly value: ImmutableDictionary
|
|
15
|
+
readonly value: ImmutableDictionary<T>;
|
|
16
16
|
readonly one: string;
|
|
17
17
|
readonly many: string;
|
|
18
18
|
readonly items: Schema<T>;
|