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
Validations in Ruby
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Krzysztof Wawer
March 23, 2016
Programming
200
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Validations in Ruby
Krzysztof Wawer
March 23, 2016
More Decks by Krzysztof Wawer
See All by Krzysztof Wawer
The Good Architecture
wafcio
0
670
GIT - Good Practices
wafcio
0
110
Slim Ruby on Rails: Controllers & Middlewares
wafcio
1
210
Dry System
wafcio
0
120
dry-validations
wafcio
0
200
Generating a CSV file with ROM
wafcio
0
370
Trailblazer bez trailblazera
wafcio
0
260
ActiveRecord, DataMapper czy Agregacja encji
wafcio
0
210
Jak (nie) używać Service Object
wafcio
0
240
Other Decks in Programming
See All in Programming
JJUG CCC 2026 Spring: JSpecify で実現する Kotlin フレンドリーな Java API 設計
ternbusty
1
170
Make SRE Operations Easier with Azure SRE Agent
kkamegawa
0
6.3k
IBM Bobを活用したレガシーアプリの最新化
oniak3ibm
PRO
1
200
RTSPクライアントを自作してみた話
simotin13
0
610
技術記事、AIに書かせるか、自分で書くか? 〜それでも私が自分の手で書く理由〜 / #QiitaConference
jnchito
2
1.4k
決定論的オーケストレーションの設計と実装 / Design and Implementation of Deterministic Orchestration
nrslib
4
1.4k
TSKaigi Night Talks 2026_TypeScriptでサプライチェーンの整合性を型に閉じ込める
geekplus_tech
0
350
New "Type" system on PicoRuby
pocke
1
950
Lessons from Spec-Driven Development
simas
PRO
0
200
不変条件と整合性境界—ビジネスが決める設計判断と実現パターン / Invariants and Consistency Boundaries
nrslib
13
5.2k
AIとASP.NET Coreで雑Webアプリを作った話
mayuki
0
640
The NotImplementedError Problem in Ruby
koic
1
800
Featured
See All Featured
Un-Boring Meetings
codingconduct
0
310
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
141
35k
Visual Storytelling: How to be a Superhuman Communicator
reverentgeek
2
560
How to audit for AI Accessibility on your Front & Back End
davetheseo
0
430
Beyond borders and beyond the search box: How to win the global "messy middle" with AI-driven SEO
davidcarrasco
3
160
Practical Orchestrator
shlominoach
191
11k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
35
3.5k
Stewardship and Sustainability of Urban and Community Forests
pwiseman
0
230
Understanding Cognitive Biases in Performance Measurement
bluesmoon
32
2.9k
Intergalactic Javascript Robots from Outer Space
tanoku
273
27k
How to train your dragon (web standard)
notwaldorf
97
6.7k
A Guide to Academic Writing Using Generative AI - A Workshop
ks91
PRO
1
330
Transcript
V ALIDATIONS IN Ruby Krzysztof W a wer 23.03.2016 TRUG
ABOUT ME • E-MAIL: krzysztof.w a
[email protected]
• Twitter: https://twitter.com/w
afcio • GITHUB: https://github.com/w afcio
V ALIDATION ???
Ruby on rails ACTIVE MODEL & ACTIVE RECORD Active Model
Active Record
ACTIVE MODEL V ALIDATIONS • acceptance • confirmation • exclusion
• format • inclusion • length • numericality • presence • uniqueness*
UNIQUENESS V ALIDATION
[email protected]
exists ?
[email protected]
exists ? Email
doesn’t exist Email doesn’t exist Create
[email protected]
Create
[email protected]
Created! Created! 1 2
UNIQUENESS V ALIDATION
UNIQUENESS V ALIDATION
[email protected]
exists ?
[email protected]
exists ? Email
doesn’t exist Email doesn’t exist Create
[email protected]
Create
[email protected]
Created! ActiveRecord::RecordNotUnique 1 2
Ruby on Rails • Strong Parameters http://edgeguides.rubyonrails.org/action_controller_overview.html#strong-parameters
STRONG PARAMETERS { name: „John”, surname: „Doe” } { name:
„John” }
STRONG PARAMETERS { name: „John”, surname: „Doe” } ActionController::UnpermittedParameters: found
unpermitted keys: surname ActionController::Parameters.action_on_unpermitted_parameters = :raise
HTTP Requests GET POST GET, POST (JSON) String String String
Integer …
HANAMI http://hanamirb.org https://github.com/hanami •hanami-controller •HANAMI-MODEL •HANAMI-HELPERS •HANAMI-MAILER •HANAMI-VIEW •HANAMI-V ALIDATIONS
•HANAMI-ASSETS •HANAMI-UTILS Luca Guidi
HANAMI-V ALIDATIONS https://github.com/hanami/v alidations#v alidations •ACCEPTANCE •CONFIRMATION •EXCLUSION •INCLUSION •PRESENCE
•FORMAT* •SIZE* •TYPE (Coercions)
HANAMI-V ALIDATIONS • numericality V ALIDATION DoesN’t Exist • „The
framework will treat as V alid any blank attributes, without PRESENCE, for both FORMAT and SIZE predicates.”
DRY https://github.com/dry-rb •DRY-AUTO_INJECT •DRY-COMPONENT •DRY-CONFIGURABLE •DRY-CONSTRUCTOR •DRY-CONTAINER •DRY-EQUALIZER •DRY-INITALIZER •DRY-LOGIC
•DRY-PIPELINE •DRY-TRANSACTION •DRY-TYPES •DRY-V ALIDATION
DRY-V ALIDATION LATEST VERSION: 0.7.0 RELEASE DATE: 16.03.2016 http://dry-rb.org/gems/dry-v alidation/
DRY-V ALIDATION When to use? V ALIDATION OF: • form
params • „GET” params • JSON params • Y AML DOCUMENTS • application configuration • replacement of ActiveRecord / ActiveModel::Validations • replacement of StrongParameters • …
???