Customize error messages (e.g. for translations)
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 5/5
- Geschätzter Aufwand
- Über eine Woche
- Anfängerfreundlichkeit
- 25/100
Rechercherichtung
Beginnen Sie mit der Dokumentation zu ValidationError und der Behandlung von additionalProperties in jsonschema/_validators.py, einschließlich der Verwendung von _utils.find_additional_properties. Prüfen Sie das zugehörige Issue #564 und den bestehenden Fehlerkontext, um den Umfang eines konfigurierbaren Nachrichtenmechanismus zu bestimmen. Als Ergebnis sollte ein geprüftes Design vorliegen, das klar beschreibt, wie übersetzte, fehlerspezifische Nachrichten unterstützt werden können, ohne die Validatorlogik zu duplizieren.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
Hi,
I would need to translate the error messages and it happens to be more complicated than I expected (or than it could be, I believe).
I started using information on ValidationErrors to define custom messages, but all relevant information for the message is not always readily available. Found this related issue #564 but with not much follow-up so I thought I could ask again.
For instance, for an "additionalProperties" keyword, looking at the code shows that there is some logic that needs to be reimplemented to make message translations (using internal _utils.find_additional_properties to find the offending properties, two different messages depending on whether properties or patternProperties is used etc.).
In addition to the overhead this introduces, I am afraid that it may drift out of sync with the logic in this package in case of improvements, bug fixes, or new draft support etc. or that internal functions may change without backward compatibility.
I am wondering if it would be possible to not hard-code messages, but use templates instead (e.g. Jinja2), that have access to error-specific contextual data (e.g. offending properties for "additionalProperties" errors), and that could be changed for a translation without touching at the logic. This is for instance the approach taken by xeipuuv/gojsonschema.
I think it would be worth a try, and I would be willing to contribute on this with a little help, if you think it is a good idea.
- Vorherrschende Sprache
- Python
- Sterne
- 5k
- Forks
- 706
- Ø Merge
- 20 Std. 29 Min.
- Gemergte PRs (30 T.)
- 2
Entwicklungsumgebung
- Kein Dockerfile und keine Docker-Compose-Datei
- Keine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus python-jsonschema/jsonschema
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
python-jsonschema/jsonschema#1598 · 1 Reaktion ·
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 65/100
python-jsonschema/jsonschema#1588 · 2 Kommentare ·
-
Iterator error contexts lose parent links and absolute pathsEvtl. wieder frei @DawnofGenX hat das vor 25 Tagen übernommen, und es ist kein Pull Request offen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 76/100
python-jsonschema/jsonschema#1584 · 3 Kommentare ·
-
regex format checker crashes with RecursionError on deeply nested patternsEvtl. vergeben @DawnofGenX hat das vor 25 Tagen übernommen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
python-jsonschema/jsonschema#1538 · 1 Kommentar ·
-
is_duration raises an uncaught decimal.Overflow on a duration with a large exponentEvtl. wieder frei Ein Pull Request dazu wurde ohne Merge geschlossen. OffenNeeds Test Upstream
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
python-jsonschema/jsonschema#1511 · 1 Kommentar ·
Alle Issues in python-jsonschema/jsonschema
Ähnliche Issues
-
infrastructure
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 76/100
NatLabRockies/H2Integrate#977 ·
Maintainer antworten meist innerhalb von 1 Tag
-
bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
topoteretes/cognee#6470 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 62/100
-
area:docs priority:p2 type:docs wave:9
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 84/100
jejjohnson/radtrax#293 ·
Maintainer antworten meist innerhalb von 1 Tag
-
bug core plugins
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
bunkerity/bunkerweb#4121 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag