1- use jsonschema:: JSONSchema ;
1+ use jsonschema:: Validator ;
22use windows:: { core:: * , Win32 :: Foundation :: * , Win32 :: System :: Com :: * } ;
33
44// Creates a JSON validator object with the given schema. The returned handle must be freed
@@ -35,16 +35,16 @@ unsafe extern "system" fn ValidateJson(
3535#[ no_mangle]
3636unsafe extern "system" fn CloseJsonValidator ( handle : usize ) {
3737 if handle != 0 {
38- _ = Box :: from_raw ( handle as * mut JSONSchema ) ;
38+ _ = Box :: from_raw ( handle as * mut Validator ) ;
3939 }
4040}
4141
4242// Implementation of the `CreateJsonValidator` function so we can use `Result` for simplicity.
4343unsafe fn create_validator ( schema : * const u8 , schema_len : usize , handle : * mut usize ) -> Result < ( ) > {
4444 let schema = json_from_raw_parts ( schema, schema_len) ?;
4545
46- let compiled = JSONSchema :: compile ( & schema )
47- . map_err ( |error| Error :: new ( E_INVALIDARG , error. to_string ( ) ) ) ?;
46+ let compiled =
47+ Validator :: new ( & schema ) . map_err ( |error| Error :: new ( E_INVALIDARG , error. to_string ( ) ) ) ?;
4848
4949 if handle. is_null ( ) {
5050 return Err ( E_POINTER . into ( ) ) ;
@@ -70,9 +70,9 @@ unsafe fn validate(
7070
7171 let value = json_from_raw_parts ( value, value_len) ?;
7272
73- // This looks a bit tricky but we're just turning the opaque handle into `JSONSchema ` pointer
73+ // This looks a bit tricky but we're just turning the opaque handle into `Validator ` pointer
7474 // and then returning a reference to avoid taking ownership of it.
75- let schema = & * ( handle as * const JSONSchema ) ;
75+ let schema = & * ( handle as * const Validator ) ;
7676
7777 if schema. is_valid ( & value) {
7878 if !sanitized_value. is_null ( ) && !sanitized_value_len. is_null ( ) {
0 commit comments