Ack 2.0: one namespace for constraint annotations (@Check.email(), @Check.minLength(2))
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 30/100
Direzione di ricerca
Start by reviewing the annotation exports in package:ack/annotations.dart and package:ack/ack.dart, the existing constraint annotation classes, and the generator entry point. Resolve the open questions about the namespace name, format annotations, and generator identification, then define tests covering the new API and deprecated aliases.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Problem
The constraint annotations are top-level classes with common names: Email, Url, Uuid, Date, Min, Max, Pattern. They clash with other libraries and with a user's own types in the same file:
package:uuiddeclaresclass Uuid; a file importing both and callingUuid()getsambiguous_import.- A user's own value type named
Email,UrlorDate, used as a field type next to@Email(), clashes the same way. Type-owned schemas (#185) encourage exactly such types. Patternshadowsdart:core'sPatternsilently, which is why it was renamed@Matchesin 1.7.
In 1.7 the constraints are exported from package:ack/annotations.dart, not from package:ack/ack.dart, and the documented way out of a clash is an import prefix (import 'package:ack/annotations.dart' as ack; and @ack.Email()). That works but depends on convention, and the list of clashing names will grow with every new constraint.
Proposal
One exported name for every constraint, with a const named constructor per constraint, mirroring the schema API:
@Check.email()
@Check.minLength(2)
@Check.matches(r'^\d+$')
final String value;
- One name to export, so it can live in
package:ack/ack.dartand a model file needs a single import. - The names match the fluent methods (
.email(),.minLength(),.matches()), so there is one vocabulary. - New constraints add a constructor, not a top-level name.
The existing annotation classes stay as deprecated aliases for one release line.
Open questions
- The name:
Check,Rule, or another word that does not collide withConstraint, which is already a runtime type inack. - Whether the format annotations (
@formats.Uri(),@formats.DateTime()) fold into the same namespace. - How the generator identifies the constraint: by constructor name, or by a kind field on the constant.
Related
- #185: type-owned schemas.
- The 1.7 pull request that moved the annotations into
ackand split the exports.
- Lingua principale
- Dart
- Stelle
- 64
- Fork
- 3
- Merge medio
- 17h 32m
- PR unite (30g)
- 33
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi 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 btwld/ack
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 42/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 68/100
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 5/5 Più di una settimana Idoneità per principianti 35/100
I maintainer di solito rispondono entro 1 giorno
-
2.0 enhancement
Difficoltà 4/5 3-5 giorni Idoneità per principianti 25/100
I maintainer di solito rispondono entro 1 giorno
-
2.0 enhancement
Difficoltà 5/5 Più di una settimana Idoneità per principianti 18/100
I maintainer di solito rispondono entro 1 giorno
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 80/100
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
fujidaiti/smooth_sheets#655 ·
I maintainer di solito rispondono entro 1 giorno
-
Drop the decision-issue rule from ARCHITECTURE.mdForse già presa @abianche l’ha presa oggi. Apertachore
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 88/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 1-3 ore Idoneità per principianti 61/100
I maintainer di solito rispondono entro 1 giorno
-
area: library feature request
Difficoltà 2/5 1-3 ore Idoneità per principianti 64/100