Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Valider dynamiquement de la donnée avec Symfony
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Marion Hurteau
April 07, 2022
Programming
1.1k
2
Share
Valider dynamiquement de la donnée avec Symfony
Symfony Live Paris - Avril 2022
Marion Hurteau
April 07, 2022
More Decks by Marion Hurteau
See All by Marion Hurteau
Les chaînes de caractères 101
marionleherisson
0
140
String usage: so many tools are already in your hands!
marionleherisson
1
200
How to dynamically validate data with Symfony
marionleherisson
0
890
La microtypographie au service de la lisibilité
marionleherisson
0
230
Other Decks in Programming
See All in Programming
クラウドネイティブなエンジニアに向ける Raycastの魅力と実際の活用事例
nealle
2
190
JOAI2026 1st solution - heron0519 -
heron0519
0
130
VueエンジニアがReactを触って感じた_設計の違い
koukimiura
0
170
AI時代のエンジニアリングの原則 / Engineering Principles in the AI Era
haru860
0
280
t *testing.T は どこからやってくるの?
otakakot
1
620
感情を設計する
ichimichi
5
1.5k
forteeの改修から振り返るPHPerKaigi 2026
muno92
PRO
3
290
iOS機能開発のAI環境と起きた変化
ryunakayama
0
180
CursorとClaudeCodeとCodexとOpenCodeを実際に比較してみた
terisuke
1
460
Vibe NLP for Applied NLP
inesmontani
PRO
0
430
ハーネスエンジニアリングとは?
kinopeee
10
5k
Vibe하게 만드는 Flutter GenUI App With ADK , 박제창, BWAI Incheon 2026
itsmedreamwalker
0
550
Featured
See All Featured
Between Models and Reality
mayunak
3
260
Un-Boring Meetings
codingconduct
0
270
世界の人気アプリ100個を分析して見えたペイウォール設計の心得
akihiro_kokubo
PRO
69
39k
Keith and Marios Guide to Fast Websites
keithpitt
413
23k
How to train your dragon (web standard)
notwaldorf
97
6.6k
Collaborative Software Design: How to facilitate domain modelling decisions
baasie
0
200
Ethics towards AI in product and experience design
skipperchong
2
260
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
31
10k
Rebuilding a faster, lazier Slack
samanthasiow
85
9.5k
How to optimise 3,500 product descriptions for ecommerce in one day using ChatGPT
katarinadahlin
PRO
1
3.5k
Applied NLP in the Age of Generative AI
inesmontani
PRO
4
2.2k
The Illustrated Children's Guide to Kubernetes
chrisshort
51
52k
Transcript
Valider dynamiquement de la donnée avec Symfony Marion Hurteau github.com/MarionLeHerisson/validation
1
Hello World 👋 Marion Hurteau @MarionHerisson /MarionLeHerisson 📧
[email protected]
Architecture Logicielle @ESGI JoliCode depuis 2019 2
Hello World 👋 Nessie & Oscar 🐈 🌱 ~40
plantes 🖥💻 RPG 3
La Validation ? 4
5
Principe Objet Contrainte Validateur 6
Principe Objet Contrainte Validateur ✅ Violation[ ] ❌ Violation[...] 7
Contrainte Validateur Entité Contrainte Validateur 8
Violations ? 9
Les contraintes 10
Il en existe beaucoup ! Blank, NotBlank IsNull, NotNull IsTrue,
IsFalse Type, Length 11
Il en existe beaucoup ! Email, Regex Url, Hostname, Ip
CssColor NotCompromisedPassword 12
Il en existe beaucoup ! Date, DateTime, Time, Timezone Choice
Language, Locale, Country File, Image 13
Il en existe beaucoup ! Bic, Ibn, CardScheme Isbn, Issn,
Isin All, AtLeastOneOf, Sequentially 14
Il en existe beaucoup ! Compound 15
Il en existe beaucoup ! Compound Callback 16
Il en existe beaucoup ! Compound Callback Expression 17
Il en existe beaucoup ! Compound Callback Expression Valid 18
Aller un peu plus loin 19
UniqueEntity 20
Auto-mapping validation 21
Auto-mapping validation 22
Différentes manières de valider 23
Sur une propriété 24
Dans un formulaire 25
Sur une méthode (un getter ou autre) 26
Sur une classe entière 27
Sur une classe entière 28
Dans mon code Lors d’un submit Quand ? 29
Groupes de validation 30
Validation personnalisée 31
Contrainte personnalisée 32
Contrainte personnalisée Une contrainte Un validateur 33
Contrainte personnalisée 34
Contrainte personnalisée 35
Dynamiques ? 36
Attends, c’est quoi un Pokémon ? 37
Attends, c’est quoi un Pokémon ? plante feu eau 38
Attends, c’est quoi un Pokémon ? niv. 18 niv. 36
39
Attends, c’est quoi un Pokémon ? 40
Attends, c’est quoi un Pokémon ? 41
Attends, c’est quoi un Pokémon ? 42
Attends, c’est quoi un Pokémon ? 43
niv. 18 niv. 36 Cas d’utilisation 44
Cas d’utilisation POST /evolution/create 45
Cas d’utilisation 46
Cas d’utilisation 47
Avec une Callback 48
Dans le controller 49
L’entité 50
Les contraintes dans l’entité 51
Les contraintes dans l’entité 52
Les contraintes dans l’entité 53
Les contraintes dans l’entité 54
Les contraintes dans l’entité 55
La callback (1/2) 56
La callback (2/2) 57
La callback (2/2) 58
ExecutionContextInterface ? 59
Design 👍 Rapide 60
Design 👍 Rapide 👎 Réutilisabilité 👎 Taille de la méthode
/ classe 👎 Testabilité 61
62
Design 👉 Externaliser les contraintes 👉 DIC 63
Avec des contraintes externes 64
La Constraint 65
La Constraint 66
Ajoutons une interface ✨ 67
Définition d’un type 68
Définition d’un type 69
On ajoute des tags 70
ContainerInterface 71
Le ConstraintValidator (1/2) 72
Le ConstraintValidator (2/2) 73
74
75 D’autres cas d’utilisation
TL;DR: 👉 Validez ! ✨ $context->getValidator()->inContext($context) 👉 Contrainte externe :
- Maintenable - Testable - Réutilisable 👉 _instanceof & !tagged_locator - + default_index_method 76
Et ensuite ? ✅ Validées 👉 Persister Avec Doctrine ?
En json ? 77
Merci ! github.com/MarionLeHerisson/validation 78
Des questions ? github.com/MarionLeHerisson/validation @MarionHerisson
[email protected]
79