Comparator Rules Page¶
Precedence tiers¶
(keyword, old_type, new_type)keyword(old_type, new_type)old_typeornew_type(single-sided)default comparator
Declaration¶
Add entries to Config.COMPARE_RULES; resolution is performed by
CompareRules.get_comparator().
Extending¶
Implement a
Comparesubclass.Register it in the rules table.
(Optional) expose it via
ConfigMakerso convenience constructors pick it up.
Per-comparator options¶
Some comparators support extra options via Config.COMPARE_CONFIG.
Example: CompareList
reads DICT_MATCH_THRESHOLD (default 0.10) to decide how strict
dict-to-dict matching inside arrays should be.
from jsonschema_diff.core import Config
from jsonschema_diff.core.custom_compare import CompareList
cfg = Config(
compare_rules={
list: CompareList,
},
compare_config={
CompareList: {
"DICT_MATCH_THRESHOLD": 0.25,
},
},
)