- This repository is archived
- No longer maintained
- All versions have been yanked from https://rubygems.org for releasing valuable namespace for others
Struct will be able to have validators for each member
Require Ruby 2.7 or later
Add below code into your Gemfile
gem 'struct-validatable', '~> 0.3.0'
require 'struct/validatable'
Person = Struct.new :name do
validator :name, AND(String, /\w+/)
end
person = Person.new
person.name = '' #=> error
person.name = +'Foo Bar' #=> pass
person.valid?(:name) #=> true
person.name.clear
person.valid?(:name) #=> false
- The pattern builder DSL is just using eqq
- Supporting
keyword_init: true
MIT License - 2011 - Kenichi Kamiya