1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | var Toast_1 = require("../../actions/Toast");
|
4 | exports.ActionType = Toast_1.ActionType;
|
5 | var type_validate_1 = require("../type-validate");
|
6 | var utils_1 = require("../utils");
|
7 | exports.toastSchema = type_validate_1.matchesObject({
|
8 | message: type_validate_1.matchesString(),
|
9 | duration: type_validate_1.matchesPositiveInteger(),
|
10 | isError: type_validate_1.makeOptional(type_validate_1.matchesBoolean()),
|
11 | });
|
12 | function validateProps(props) {
|
13 | return type_validate_1.validate(props, exports.toastSchema);
|
14 | }
|
15 | exports.validateProps = validateProps;
|
16 | function validateAction(action) {
|
17 | switch (action.type) {
|
18 | case Toast_1.ActionType.SHOW:
|
19 | return type_validate_1.validate(action, utils_1.createActionValidator(Toast_1.ActionType, exports.toastSchema, true));
|
20 | default:
|
21 | return type_validate_1.validate(action, utils_1.createActionValidator(Toast_1.ActionType));
|
22 | }
|
23 | }
|
24 | exports.validateAction = validateAction;
|