Introduce ErrorsAware interface and a base trait implementation
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 38/100
Direzione di ricerca
Inizia leggendo src/PostValidationHookInterface.php, che l’issue identifica come modello per la marker interface. Chiarisci quindi come ErrorsAwareInterface e il trait di base proposti debbano rappresentare gli errori singoli e mappati, incluso il caso di restituzione Stringable-or-array. Il lavoro è completo quando l’interfaccia e il trait forniscono tutti i metodi elencati e supportano l’utilizzo del validator mostrato nell’issue.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
ErrorsAwareInterface is a marker same as PostValidationHookInterface.
It may set all errors after validation into an validated object. It may unify forms and request-model.
interface ErrorsAwareInterface {
public function addError(string $attribute): void;
public function getError(string $attribute): mixed; <-- either Stringable or Stringable[]
public function hasError(string $attribute): bool;
public function setErrors(array $errorsMap): void;
public function getErrors(): array;
public function hasErrors(): bool;
}
So the base trait should implement all of these methods;
Usage is simple:
$validator->validate($object);
if ($object->hasErrors()) {
// ...
}
Instead of
$result = $validator->validate($object);
if ($result->hasErrors()) {
// ...
}
It may be useful with nested structures that may be hard accessible and just a shortcut to pass both errors and the object somewhere together.
- Lingua principale
- PHP
- Stelle
- 167
- Fork
- 47
- Merge medio
- 1g 19h
- PR unite (30g)
- 3
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di yiisoft/validator
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 65/100
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 68/100
-
Multibyte trim support Aperta
Difficoltà 3/5 1-2 giorni Idoneità per principianti 62/100
-
type:bug
Tutte le issue di yiisoft/validator
Issue simili
-
tooling
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
-
UX
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
ProfessionalWiki/NeoWiki#1525 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
-
bug customer-reported
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
MagnaCapax/PMSS#949 ·
-
responsive-media kses allow-list strips clipPathUnits, collapsing objectBoundingBox clip paths Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
Automattic/static-site-importer#1829 ·