Are you happy with your logging solution? Would you help us out by taking a 30-second survey? Click here

kawaii_validation

An ActiveRecord extension that adds more kawaii validation syntax

Subscribe to updates I use kawaii_validation


Statistics on kawaii_validation

Number of watchers on Github 113
Number of open issues 1
Main language Ruby
Average time to merge a PR about 2 hours
Open pull requests 0+
Closed pull requests 1+
Last commit over 2 years ago
Repo Created over 6 years ago
Repo Last Updated over 1 year ago
Size 21 KB
Organization / Authoramatsuda
Contributors2
Page Updated
Do you use kawaii_validation? Leave a review!
View kawaii_validation activity
View on github
Fresh, new opensource launches 🚀🚀🚀
Trendy new open source projects in your inbox! View examples

Subscribe to our mailing list

Evaluating kawaii_validation for your project? Score Explanation
Commits Score (?)
Issues & PR Score (?)

KawaiiValidation

Build Status

An ActiveRecord extension that adds more kawaii validation syntax.

Motivation

The Sexy Validation syntax is not at all sexy.

Installation

Gemfile:

gem 'kawaii_validation'

And then execute:

$ bundle

Supported versions

  • Ruby 2.0, 2.1, 2.2, 2.3, 2.4, and 2.5 (trunk)

  • Rails 3.2.x, 4.0, 4.1, 4.2, 5.0, 5.1, and 5.2 (edge)

Usage

With this gem bundled, the validates method takes a block argument, and the following two new DSLs will be enabled:

  • Original code (so-called Sexy Validation)
class User < ActiveRecord::Base
  # validations begin
  validates :name, :age, presence: true
  validates :name, length: {maximum: 255}
  validates :age, numericality: {greater_than: 0}
  # validations end

  ...
end
  • validates + block
class User < ActiveRecord::Base
  validates do
    presence_of :name, :age
    length_of :name, maximum: 255
    numericality_of :age, greater_than: 0
  end

  ...
end
  • validates + attributes + block
class User < ActiveRecord::Base
  validates :name do
    presence
    length maximum: 255
  end

  validates :age do
    presence
    numericality greater_than: 0
  end

  ...
end

Contributing

  • Send me your pull requests!
kawaii_validation open issues Ask a question     (View All Issues)
  • over 6 years allow to pass options directly from `validates`
kawaii_validation list of languages used
Other projects in Ruby