Create New Item
Item Type
File
Folder
Item Name
Search file in folder and subfolders...
Are you sure want to rename?
optometrists
/
cache
/
cache
/
cache
/
cache
/
cache
/
cache
/
.wp-cli
/
wp-content
/
plugins
/
woocommerce
/
packages
/
woocommerce-blocks
/
assets
/
js
/
blocks-registry
/
payment-methods
:
assertions.js
Advanced Search
Upload
New Item
Settings
Back
Back Up
Advanced Editor
Save
/** * External dependencies */ import { isValidElement } from '@wordpress/element'; export const assertValidPaymentMethodComponent = ( component, componentName ) => { if ( typeof component !== 'function' ) { throw new TypeError( `The ${ componentName } property for the payment method must be a functional component` ); } }; export const assertValidElement = ( element, elementName ) => { if ( element !== null && ! isValidElement( element ) ) { throw new TypeError( `The ${ elementName } property for the payment method must be a React element or null.` ); } }; export const assertValidElementOrString = ( element, elementName ) => { if ( element !== null && ! isValidElement( element ) && typeof element !== 'string' ) { throw new TypeError( `The ${ elementName } property for the payment method must be a React element, a string, or null.` ); } }; export const assertConfigHasProperties = ( config, expectedProperties = [] ) => { const missingProperties = expectedProperties.reduce( ( acc, property ) => { if ( ! config.hasOwnProperty( property ) ) { acc.push( property ); } return acc; }, [] ); if ( missingProperties.length > 0 ) { const message = 'The payment method configuration object is missing the following properties:'; throw new TypeError( message + missingProperties.join( ', ' ) ); } };