yaml-validator
yaml-validator copied to clipboard
Simple typo-detection by matching MissingField with ExtraField
Misspelling a field in a strictly typed object presently results in a SchemaError::Multiple(FieldMissing, ExtraField) error. It would be cool to do some simple levenshtein distance on these two field names to suggest a typo was made if the similarity is high.
SchemaError {
kind: Multiple {
errors: [
SchemaError {
kind: FieldMissing { field: "not" },
},
SchemaError {
kind: ExtraField { field: "note" },
}
]
}
Would thereby be transformed into:
SchemaError {
kind: Typo {
extected: "not",
found: "note",
}
}
This should probably be implemented in the CLI-tool instead of in the library itself, since there's no reason to increase the possible number of error cases to handle, and it is mostly an aesthetic improvement.