@@ -387,6 +387,104 @@ impl<F: FnMut(Change)> DiffWalker<F> {
387387 }
388388 }
389389
390+ fn diff_pattern ( & mut self , json_path : & str , lhs : & mut SchemaObject , rhs : & mut SchemaObject ) {
391+ let lhs_pattern = & lhs. string ( ) . pattern ;
392+ let rhs_pattern = & rhs. string ( ) . pattern ;
393+
394+ match ( lhs_pattern, rhs_pattern) {
395+ ( Some ( lhs_pat) , Some ( rhs_pat) ) if lhs_pat != rhs_pat => {
396+ ( self . cb ) ( Change {
397+ path : json_path. to_owned ( ) ,
398+ change : ChangeKind :: PatternChange {
399+ old_pattern : lhs_pat. clone ( ) ,
400+ new_pattern : rhs_pat. clone ( ) ,
401+ } ,
402+ } ) ;
403+ }
404+ ( Some ( removed_pat) , None ) => {
405+ ( self . cb ) ( Change {
406+ path : json_path. to_owned ( ) ,
407+ change : ChangeKind :: PatternRemove {
408+ removed : removed_pat. clone ( ) ,
409+ } ,
410+ } ) ;
411+ }
412+ ( None , Some ( added_pat) ) => {
413+ ( self . cb ) ( Change {
414+ path : json_path. to_owned ( ) ,
415+ change : ChangeKind :: PatternAdd {
416+ added : added_pat. clone ( ) ,
417+ } ,
418+ } ) ;
419+ }
420+ _ => { } // No change or both None
421+ }
422+ }
423+
424+ fn diff_min_length ( & mut self , json_path : & str , lhs : & mut SchemaObject , rhs : & mut SchemaObject ) {
425+ let lhs_min = lhs. string ( ) . min_length ;
426+ let rhs_min = rhs. string ( ) . min_length ;
427+
428+ match ( lhs_min, rhs_min) {
429+ ( Some ( lhs_val) , Some ( rhs_val) ) if lhs_val != rhs_val => {
430+ ( self . cb ) ( Change {
431+ path : json_path. to_owned ( ) ,
432+ change : ChangeKind :: MinLengthChange {
433+ old_value : lhs_val,
434+ new_value : rhs_val,
435+ } ,
436+ } ) ;
437+ }
438+ ( Some ( removed_val) , None ) => {
439+ ( self . cb ) ( Change {
440+ path : json_path. to_owned ( ) ,
441+ change : ChangeKind :: MinLengthRemove {
442+ removed : removed_val,
443+ } ,
444+ } ) ;
445+ }
446+ ( None , Some ( added_val) ) => {
447+ ( self . cb ) ( Change {
448+ path : json_path. to_owned ( ) ,
449+ change : ChangeKind :: MinLengthAdd { added : added_val } ,
450+ } ) ;
451+ }
452+ _ => { } // No change or both None
453+ }
454+ }
455+
456+ fn diff_max_length ( & mut self , json_path : & str , lhs : & mut SchemaObject , rhs : & mut SchemaObject ) {
457+ let lhs_max = lhs. string ( ) . max_length ;
458+ let rhs_max = rhs. string ( ) . max_length ;
459+
460+ match ( lhs_max, rhs_max) {
461+ ( Some ( lhs_val) , Some ( rhs_val) ) if lhs_val != rhs_val => {
462+ ( self . cb ) ( Change {
463+ path : json_path. to_owned ( ) ,
464+ change : ChangeKind :: MaxLengthChange {
465+ old_value : lhs_val,
466+ new_value : rhs_val,
467+ } ,
468+ } ) ;
469+ }
470+ ( Some ( removed_val) , None ) => {
471+ ( self . cb ) ( Change {
472+ path : json_path. to_owned ( ) ,
473+ change : ChangeKind :: MaxLengthRemove {
474+ removed : removed_val,
475+ } ,
476+ } ) ;
477+ }
478+ ( None , Some ( added_val) ) => {
479+ ( self . cb ) ( Change {
480+ path : json_path. to_owned ( ) ,
481+ change : ChangeKind :: MaxLengthAdd { added : added_val } ,
482+ } ) ;
483+ }
484+ _ => { } // No change or both None
485+ }
486+ }
487+
390488 fn resolve_references (
391489 & self ,
392490 lhs : & mut SchemaObject ,
@@ -496,6 +594,9 @@ impl<F: FnMut(Change)> DiffWalker<F> {
496594 }
497595 self . diff_const ( json_path, lhs, rhs) ;
498596 self . diff_format ( json_path, lhs, rhs) ;
597+ self . diff_pattern ( json_path, lhs, rhs) ;
598+ self . diff_min_length ( json_path, lhs, rhs) ;
599+ self . diff_max_length ( json_path, lhs, rhs) ;
499600 // If we split the types, we don't want to compare type-specific properties
500601 // because they are already compared in the `Self::diff_any_of`
501602 if !is_lhs_split && !is_rhs_split {
0 commit comments