Sha256: d557cf3453510835e0400557c4999c292aef987deade8a5d50e14f89d3df9658

Contents?: true

Size: 1.36 KB

Versions: 1

Compression:

Stored size: 1.36 KB

Contents

# Yema

[![Build Status](https://travis-ci.org/handiwiguna/yema.png?branch=master)](https://travis-ci.org/handiwiguna/yema)
[![Code Climate](https://codeclimate.com/github/handiwiguna/yema.png)](https://codeclimate.com/github/handiwiguna/yema)

## Installation

Add this line to your application's Gemfile:

    gem 'yema'

And then execute:

    $ bundle

Or install it yourself as:

    $ gem install yema

## Usage

Inline:

```ruby
validator = Yema::Validator.new(params, Yema::Rule::Required.new(:title))
validator.valid?
```

Class:

```ruby
class User
  include Yema::Validations
  attr_accessor :age
end

User.rules.add(Yema::Rule::StrongType.new(:age, type: Integer))

user = User.new
user.age = 3
user.valid? # => true

user.age = '3'
user.valid? # => true

user.age = 'abc'
user.valid? # => false
```

Virtus Integration:

```ruby
class UserParam
  include Yema::Virtus::Validations
  attribute :age, Integer, required: true
end

user = UserParam.new(age: 2)
user.valid? # => true

user = UserParam.new(age: '2')
user.valid? # => true

user = UserParam.new(age: 'abc')
user.valid? # => false

user = UserParam.new
user.valid? # => false
```

## Contributing

1. Fork it
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create new Pull Request

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
yema-0.0.3 README.md