@shopify/app-bridge-core
Version:
**[Join our team and work on libraries like this one.](https://www.shopify.ca/careers)**
26 lines (23 loc) • 886 B
JavaScript
import { Action } from '../../actions/Toast/index.js';
import { matchesObject, validate, matchesString, matchesPositiveInteger, makeOptional, matchesBoolean } from '../type-validate.js';
import { createActionValidator } from '../utils.js';
const toastSchema = matchesObject({
message: matchesString(),
duration: matchesPositiveInteger(),
isError: makeOptional(matchesBoolean()),
action: makeOptional(matchesObject({
content: matchesString(),
})),
});
function validateAction(action) {
switch (action.type) {
case Action.SHOW:
return validate(action, createActionValidator(Action, toastSchema, true));
default:
return validate(action, createActionValidator(Action));
}
}
function validateProps(props) {
return validate(props, toastSchema);
}
export { Action, toastSchema, validateAction, validateProps };