shelving 1.22.0 → 1.22.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/api/Resource.d.ts +8 -1
- package/api/Resource.js +10 -1
- package/package.json +1 -1
package/api/Resource.d.ts
CHANGED
|
@@ -12,9 +12,16 @@ export declare class Resource<P = unknown, R = void> implements Validatable<R> {
|
|
|
12
12
|
readonly result: Validator<R>;
|
|
13
13
|
constructor(payload: Validator<P>, result: Validator<R>);
|
|
14
14
|
/**
|
|
15
|
-
* Validate a
|
|
15
|
+
* Validate a payload for this resource.
|
|
16
16
|
*
|
|
17
17
|
* @returns The validated payload for this resource.
|
|
18
|
+
* @throws InvalidFeedback if the payload could not be validated.
|
|
19
|
+
*/
|
|
20
|
+
prepare(unsafePayload: unknown): P;
|
|
21
|
+
/**
|
|
22
|
+
* Validate a result for this resource.
|
|
23
|
+
*
|
|
24
|
+
* @returns The validated result for this resource.
|
|
18
25
|
* @throws ValidationError if the result could not be validated.
|
|
19
26
|
*/
|
|
20
27
|
validate(unsafeResult: unknown): R;
|
package/api/Resource.js
CHANGED
|
@@ -14,9 +14,18 @@ export class Resource {
|
|
|
14
14
|
this.result = result;
|
|
15
15
|
}
|
|
16
16
|
/**
|
|
17
|
-
* Validate a
|
|
17
|
+
* Validate a payload for this resource.
|
|
18
18
|
*
|
|
19
19
|
* @returns The validated payload for this resource.
|
|
20
|
+
* @throws InvalidFeedback if the payload could not be validated.
|
|
21
|
+
*/
|
|
22
|
+
prepare(unsafePayload) {
|
|
23
|
+
return validate(unsafePayload, this.payload);
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Validate a result for this resource.
|
|
27
|
+
*
|
|
28
|
+
* @returns The validated result for this resource.
|
|
20
29
|
* @throws ValidationError if the result could not be validated.
|
|
21
30
|
*/
|
|
22
31
|
validate(unsafeResult) {
|