UNPKG

@shopify/app-bridge

Version:

> **Maintenance Mode:** Although apps using this package will continue to function, it is no longer receiving updates. For new projects, please use the [CDN version of App Bridge](https://shopify.dev/docs/api/app-home?accordionItem=getting-started-build-y

20 lines (19 loc) 1.26 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Action = exports.validateAction = void 0; var Share_1 = require("../../actions/Share"); var type_validate_1 = require("../type-validate"); var utils_1 = require("../utils"); function validateAction(action) { var urlProvided = (0, type_validate_1.matchesObject)({ text: (0, type_validate_1.makeOptional)((0, type_validate_1.matchesString)()), url: (0, type_validate_1.matchesString)() }); var textProvided = (0, type_validate_1.matchesObject)({ text: (0, type_validate_1.matchesString)(), url: (0, type_validate_1.makeOptional)((0, type_validate_1.matchesString)()) }); var urlError = (0, type_validate_1.validate)(action, (0, utils_1.createActionValidator)(Share_1.Action, urlProvided)); var textError = (0, type_validate_1.validate)(action, (0, utils_1.createActionValidator)(Share_1.Action, textProvided)); if (!urlError || !textError) { return; } return Object.prototype.hasOwnProperty.call(action.payload, 'url') ? urlError : textError; } exports.validateAction = validateAction; var Share_2 = require("../../actions/Share"); Object.defineProperty(exports, "Action", { enumerable: true, get: function () { return Share_2.Action; } });