WordPress at Your Fingertips
function is not described

WC_REST_Controller::validate_setting_select_field() public WC 3.0.0

Validate select based settings.

{} It's a method of the class: WC_REST_Controller{}

No Hooks.

Return

String|WP_Error.

Usage

$WC_REST_Controller = new WC_REST_Controller();
$WC_REST_Controller->validate_setting_select_field( $value, $setting );
$value(string) (required)
Value.
$setting(array) (required)
Setting.

Changelog

Since 3.0.0 Introduced.

Code of WC_REST_Controller::validate_setting_select_field() WC 5.9.0

public function validate_setting_select_field( $value, $setting ) {
	if ( array_key_exists( $value, $setting['options'] ) ) {
		return $value;
	} else {
		return new WP_Error( 'rest_setting_value_invalid', __( 'An invalid setting value was passed.', 'woocommerce' ), array( 'status' => 400 ) );
	}
}