Skip to content

MishaConway/sequel_validation_exceptions

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 

Repository files navigation

Installation:
1) install the gem
gem install sequel_validation_exceptions
2) specify the plugin in your sequel model
plugin :validation_exceptions

In a similar vein to the ActiveRecord ORM, this sequel plugin adds save!, update!, create!, and find_or_create! to the sequel model class. All of these methods will raise a Sequel::ValidationException if validation fails.

Examples:
>> blog = Blog.new :title => ''
>> blog.save!
    Sequel::ValidationException: Could not save new Blog model due to failing validation: {:title=>["is not present"]}

>> blog = Blog.first
>> blog.update! :title => nil
    Sequel::ValidationException: Could not save Blog model due to failing validation: {:title=>["is not present"]}

>> blog = Blog.create!
    Sequel::ValidationException: Could not save new Blog model due to failing validation: {:title=>["is not present"]}

>> blog = Blog.find_or_create! :title => ''
    Sequel::ValidationException: Could not save new Blog model due to failing validation: {:title=>["is not present"]}



About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages