• Stars
    star
    213
  • Rank 185,410 (Top 4 %)
  • Language
    Ruby
  • License
    MIT License
  • Created about 10 years ago
  • Updated 12 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Validation mixin for Ruby objects

Hanami::Validations

Internal support gem for Hanami::Action params validation.

Status

Gem Version CI Test Coverage Depfu Inline Docs

Version

This branch contains the code for hanami-validations 2.x.

Contact

Rubies

Hanami::Validations supports Ruby (MRI) 3.0+

Installation

Add this line to your application's Gemfile:

gem "hanami-validations"

And then execute:

$ bundle

Or install it yourself as:

$ gem install hanami-validations

Usage

Installing hanami-validations enables support for params validation in hanami-controller’s Hanami::Action classes.

class Signup < Hanami::Action
  params do
    required(:first_name)
    required(:last_name)
    required(:email)
  end

  def handle(req, *)
    puts req.params.class            # => Signup::Params
    puts req.params.class.superclass # => Hanami::Action::Params

    puts req.params[:first_name]     # => "Luca"
    puts req.params[:admin]          # => nil
  end
end

See hanami-controller for more detail on params validation.

Contributing

  1. Fork it ( https://github.com/hanami/validations/fork )
  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 a new Pull Request

Copyright

Copyright © 2014 Hanami Team – Released under MIT License

More Repositories

1

hanami

The web, with simplicity.
Ruby
6,147
star
2

model

Ruby persistence framework with entities and repositories
Ruby
445
star
3

router

Ruby/Rack HTTP router
Ruby
360
star
4

api

Minimal, lightweight, fastest Ruby framework for HTTP APIs.
Ruby
342
star
5

controller

Complete, fast and testable actions for Rack and Hanami
Ruby
245
star
6

utils

Ruby core extentions and class utilities for Hanami
Ruby
173
star
7

view

Views, templates and presenters for Ruby web applications
Ruby
171
star
8

hanami-2-application-template

Hanami 2 application starter template
Ruby
107
star
9

hanami.github.io

Hanami website
HTML
88
star
10

helpers

View helpers for Ruby applications
Ruby
79
star
11

guides

Hanami Guides
CSS
51
star
12

mailer

Mail for Ruby applications
Ruby
48
star
13

assets

Assets management for Ruby web applications
Ruby
47
star
14

events

[Experimental] Events framework for Hanami
Ruby
43
star
15

cli

Hanami command line
Ruby
25
star
16

bookshelf

Hanami "Getting Started" project
Ruby
21
star
17

contributors

All hanami contributors in one place
Ruby
14
star
18

reloader

Code reloading for Hanami 2
Ruby
14
star
19

ecosystem

Hanami Ecosystem
12
star
20

snippets

Learn Hanami by reading, short, curated, manually crafted code snippets.
CSS
10
star
21

webconsole

Hanami web console for development
Ruby
7
star
22

community

7
star
23

ujs

Hanami UJS
Ruby
4
star
24

devtools

Hanami development tools [internal usage]
Ruby
4
star
25

docs

Hanami API Docs
CSS
4
star
26

rspec

Hanami RSpec extensions
Ruby
3
star
27

assets-js

esbuild plugin for Hanami Assets
TypeScript
3
star
28

guides-v2

Working area for new Hanami 2.0 guides; these will be merge into the main guides repo before 2.0 release.
2
star
29

model-sql

Hanami Model SQL
Ruby
1
star
30

playbook

Ruby
1
star
31

docker-ci-images

Docker images to be used with our CI
Dockerfile
1
star