wpseek.com
A WordPress-centric search engine for devs and theme authors



rest_validate_json_schema_pattern › WordPress Function

Since5.6.0
Deprecatedn/a
rest_validate_json_schema_pattern ( $pattern, $value )
Parameters: (2)
  • (string) $pattern The pattern to match against.
    Required: Yes
  • (string) $value The value to check.
    Required: Yes
Returns:
  • (bool) True if the pattern matches the given value, false otherwise.
Defined at:
Codex:

Validates if the JSON Schema pattern matches a value.



Source

function rest_validate_json_schema_pattern( $pattern, $value ) {
	$escaped_pattern = str_replace( '#', '\\#', $pattern );

	return 1 === preg_match( '#' . $escaped_pattern . '#u', $value );
}