Validates if the JSON Schema pattern matches a value.
Parameters
$pattern
stringrequired- The pattern to match against.
$value
stringrequired- The value to check.
Source
function rest_validate_json_schema_pattern( $pattern, $value ) {
$escaped_pattern = str_replace( '#', '\\#', $pattern );
return 1 === preg_match( '#' . $escaped_pattern . '#u', $value );
}
Changelog
Version | Description |
---|---|
5.6.0 | Introduced. |
User Contributed Notes
You must log in before being able to contribute a note or feedback.