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
Krzysztof Wawer
March 23, 2016
Programming
200
0
Share
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
100
Slim Ruby on Rails: Controllers & Middlewares
wafcio
1
200
Dry System
wafcio
0
120
dry-validations
wafcio
0
190
Generating a CSV file with ROM
wafcio
0
360
Trailblazer bez trailblazera
wafcio
0
250
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
【26新卒研修】OpenAPI/Swagger REST API研修
dip_tech
PRO
0
140
書き換えて学ぶTemporal #fukts
pirosikick
2
350
PHPでローカル環境用のSSL/TLS証明書を発行することはできるのか? #phpconkagawa
akase244
0
330
My daily life on Ruby
a_matsuda
3
180
How We Practice Exploratory Testing in Iterative Development( #scrumniigata ) / 反復開発の中で、探索的テストをどう実施しているか
teyamagu
PRO
3
700
Building on Bluesky's AT Protocol with Ruby
mackuba
0
100
Firefoxにコントリビューションして得られた学び
ken7253
2
150
Claude Code × Gemini × Ebitengine ゲーム制作素人WebエンジニアがGoでゲームを作った話
webzawa
0
220
AIと共に生きる技術選定 2026
sgash708
0
120
検索設計から 推論設計への重心移動と Recall-First Retrieval
po3rin
5
1.5k
実用!Hono RPC2026
yodaka
2
300
Agentic Elixir
whatyouhide
0
440
Featured
See All Featured
Kristin Tynski - Automating Marketing Tasks With AI
techseoconnect
PRO
0
240
Abbi's Birthday
coloredviolet
2
7.4k
Building Applications with DynamoDB
mza
96
7k
How to Align SEO within the Product Triangle To Get Buy-In & Support - #RIMC
aleyda
2
1.5k
The Curse of the Amulet
leimatthew05
1
12k
The Invisible Side of Design
smashingmag
302
52k
Introduction to Domain-Driven Design and Collaborative software design
baasie
1
770
Lightning Talk: Beautiful Slides for Beginners
inesmontani
PRO
1
530
A Guide to Academic Writing Using Generative AI - A Workshop
ks91
PRO
1
290
Google's AI Overviews - The New Search
badams
0
1k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
12
1.6k
AI in Enterprises - Java and Open Source to the Rescue
ivargrimstad
0
1.3k
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 • …
???