Validation errors should be able to indicate that a single error should be produced without collecting all of the details ahead of time

Aperta
#517 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 6 giorni

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
5/5
Tempo stimato
Più di una settimana
Idoneità per principianti
30/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
python
Ambito
backend

Direzione di ricerca

Inizia tracciando i percorsi di validazione per anyOf, oneOf e dependentRequired, quindi esamina come ValidationError.init riceve il contesto. Il lavoro è completato quando è possibile restituire un errore di validazione senza raccogliere tutti i sotto-errori, mentre il suo contenuto completo viene calcolato solo quando richiesto.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Dialects v2 Enhancement Error Reporting

In general, validation is lazy -- if only one error is needed (in the sense that it is known that an instance is invalid), only one is produced.

There are however (somewhat unintentional) exceptions.

E.g.:

  • anyOf and oneOf calculate the .context of the first error they yield by calculating all sub-errors that were generated. This is because ValidationError.context needs to be provided on __init__.
  • dependentRequired, on the other hand, yields many errors, one for each missing required property (see also #119)

What's happening in these situations is that the validation function knows an error has occurred -- it wants to yield an error, but in order to do so, it needs to calculate the full details required so that the error is "complete".

We should instead have a way to indicate a validation error has occurred, but delay fully calculating its contents until/unless they are requested.

Lingua principale
Python
Stelle
5k
Fork
741
Merge medio
4g 17h
PR unite (30g)
6

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di python-jsonschema/jsonschema

Tutte le issue di python-jsonschema/jsonschema

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.