[Feature Request] Support validation id in Standard Schema

Aperta
#133 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
45/100
Tipo di issue
Funzionalità
Chiarezza
Da chiarire
Stato di attività
Attiva
Stack tecnologico
typescript
Ambito
api

Direzione di ricerca

Non viene indicato alcun file, test o punto di ingresso. Inizia tracciando come la validation id di proto diventa attualmente un Standard Schema Issue e analizza la struttura di Issue e la gestione dei messaggi esistente. Il lavoro è completo quando l’id è disponibile per una UI per id senza doverlo duplicare nel messaggio di errore visibile all’utente.

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

Descrizione

Feature

Feature description:

Right now, the validation id defined in proto doesn't get passed into standard schema. We have some per-id specific UI to show, but all we get now is the error message. That's understandable since the Issue type doesn't have an additional field to store that meta.

  /** The issue interface of the failure output. */
  export interface Issue {
    /** The error message of the issue. */
    readonly message: string;
    /** The path of the issue, if any. */
    readonly path?: ReadonlyArray<PropertyKey | PathSegment> | undefined;
  }

Problem it solves or use case:

There are certain multi-field validations where we'd like to highlight the specific fields involved, vs just a generic parent message that contains the fields

Proposed implementation or solution:

Today, we manually copy the id to the front of the error message. Our pattern looks like:

{{id}}::{{message}}

We can split in our form code and use the id as an immutable id, while retaining the ability to make user friendly error messages.

The primary issue with this is that we now have the id repeated twice and have to make sure they stay in sync. If we could have protovalidate export standard schema by templating the Issue message, that would solve this problem.

Maybe there's a better approach, open to suggestions.

Contribution:

We could contribute it if the direction is agreeable

Additional context:

cc @seancassiere

Lingua principale
TypeScript
Stelle
85
Fork
14
Merge medio
2m
PR unite (30g)
1

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 bufbuild/protovalidate-es

Tutte le issue di bufbuild/protovalidate-es

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.