kemalyst-validators
Version, currently 0.1.02 versions
- 0.2.0latestJan 29, 2017
- 0.1.0not indexedJan 29, 2017
github.com/kemalyst/kemalyst-validators
Mix-in that provides validation methods to model objects
Nothing has been indexed for 0.1.0 yet. The tag is recorded, its shard.yml has not been read, so the manifest and dependency list below are empty because they are unknown rather than because they are absent.
Installation
# Add this to your shard.yml
dependencies:
kemalyst-validators:
github: kemalyst/kemalyst-validators
version: ~> 0.1.0Then run:
shards installshard.yml
No shard.yml has been indexed for 0.1.0. You can read it on the repository.
Dependencies
Unknown: the shard.yml for this version has not been read yet.
README
This README is the one indexed from the repository at its latest ref, not from the tag for this version.
Kemalyst Validators
Kemalyst Validators provides a standard way of creating validation for models. The library is built for Kemalyst but can be leveraged by any plain old object.
Installation
Add this to your application's shard.yml:
dependencies:
kemalyst-validators:
github: drujensen/kemalyst-validators
Usage
Kemalyst::Validators is a mix-in that you include in your class:
require "kemalyst-validators"
class Person
include Kemalyst::Validators
property name : String?
validate :name, "is required", -> (this : Person) { this.name != nil }
validate :name, "must be 3 characters long", -> (this : Person) do
if name = this.name
return name.size > 2
end
return true
end
def initialize(@name = nil)
end
end
The validate macro takes three parameters. The symbol of the field and the message that will
display when the validation fails. The third is a Proc that is provided an
instance of self and returns either true or false.
To check to see if your instance is valid, call valid?. Each Proc will be
called and if any of them fails, an errors Array with the messages is
returned.
If no Symbol is provided as a first parameter, the errors will be added to the :base field.
person = Person.new(name: "JD")
person.valid?.should eq false
person.errors[0].to_s.should eq "Name must be 3 characters long"
Development
RoadMap:
- [] Provide standard validators that can be used per field
Contributing
- Fork it ( https://github.com/drujensen/kemalyst-validators/fork )
- Create your feature branch (git checkout -b my-new-feature)
- Commit your changes (git commit -am 'Add some feature')
- Push to the branch (git push origin my-new-feature)
- Create a new Pull Request
Contributors
- drujensen Dru Jensen - creator, maintainer
Documentation
Built from the current release. The first visit to a release nobody has asked for starts its build.
Links
This release
- Version
0.1.0- Tagged
- Jan 29, 2017
- Commit
850824241c31- Indexed
- not yet
Dependents
Repository
github.com/kemalyst/kemalyst-validators
Metadata
- Created
- Aug 19, 2026
- Updated
- Nov 18, 2026
- Synced
- Nov 18, 2026
- Versions
- 2