Validate Models
Basic Model Validation
class User
include CQL::Model(User, Int64)
property id : Int64?
property name : String
property email : String
property age : Int32?
validate name, presence: true, length: {min: 2, max: 100}
validate email, presence: true, format: /@/
validate age, numericality: {greater_than: 0, less_than: 150}, allow_nil: true
endValidation Rules
Presence
Uniqueness
Length
Format
Numericality
Inclusion
Custom Model Validation
Validation Callbacks
Checking Validity
Skipping Validations
Validation Contexts
See Also
Last updated
Was this helpful?
