A WordPress-centric search engine for devs and theme authors



rest_validate_boolean_value_from_schema ›

Since5.7.0
Deprecatedn/a
rest_validate_boolean_value_from_schema ( $value, $param )
Parameters: (2)
  • (mixed) $value The value to validate.
    Required: Yes
  • (string) $param The parameter name, used in error messages.
    Required: Yes
Returns:
  • (true|WP_Error)
Defined at:
Codex:

Validates a boolean value based on a schema.



Source

function rest_validate_boolean_value_from_schema( $value, $param ) {
	if ( ! rest_is_boolean( $value ) ) {
		return new WP_Error(
			'rest_invalid_type',
			/* translators: 1: Parameter, 2: Type name. */
			sprintf( __( '%1$s is not of type %2$s.' ), $param, 'boolean' ),
			array( 'param' => $param )
		);
	}

	return true;
}