rest_validate_json_schema_pattern

函式
rest_validate_json_schema_pattern ( $pattern, $value )
引數
  • (string) $pattern The pattern to match against.
    Required:
  • (string) $value The value to check.
    Required:
返回值
  • (bool) True if the pattern matches the given value, false otherwise.
定義位置
相關方法
rest_validate_value_from_schemarest_validate_string_value_from_schemarest_validate_boolean_value_from_schemarest_validate_null_value_from_schemarest_validate_enum
引入
5.6.0
棄用
-

rest_validate_json_schema_pattern: 這是一個WordPress函式,用於驗證一個值是否與JSON模式中指定的正規表示式模式相匹配: 該函式接收一個值引數和一個模式引數,如果該值與模式不匹配,則返回一個錯誤資訊。

驗證JSON模式是否與一個值匹配。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
function rest_validate_json_schema_pattern( $pattern, $value ) {
$escaped_pattern = str_replace( '#', '\#', $pattern );
return 1 === preg_match( '#' . $escaped_pattern . '#u', $value );
}
function rest_validate_json_schema_pattern( $pattern, $value ) { $escaped_pattern = str_replace( '#', '\#', $pattern ); return 1 === preg_match( '#' . $escaped_pattern . '#u', $value ); }
function rest_validate_json_schema_pattern( $pattern, $value ) {
	$escaped_pattern = str_replace( '#', '\#', $pattern );

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

常見問題

FAQs
檢視更多 >