All Projects → melekes → Valle

melekes / Valle

Licence: mit
UNMAINTAINED Built-in limit validations for your ActiveRecord model

Programming Languages

ruby
36898 projects - #4 most used programming language

Projects that are alternatives of or similar to Valle

Html5 validators
A gem/plugin for Rails 3, Rails 4, Rails 5, and Rails 6 that enables client-side validation using ActiveModel + HTML5 Form Validation
Stars: ✭ 302 (+193.2%)
Mutual labels:  activerecord, validations
Active record replica
Redirect ActiveRecord (Rails) reads to replica databases while ensuring all writes go to the primary database.
Stars: ✭ 96 (-6.8%)
Mutual labels:  activerecord
Csvpack
csvpack library / gem - tools 'n' scripts for working with tabular data packages using comma-separated values (CSV) datafiles in text with meta info (that is, schema, datatypes, ..) in datapackage.json; download, read into and query CSV datafiles with your SQL database (e.g. SQLite, PostgreSQL, ...) of choice and much more
Stars: ✭ 71 (-31.07%)
Mutual labels:  activerecord
Resty
The minimalist framework of RESTful(server and client) - Resty
Stars: ✭ 1,268 (+1131.07%)
Mutual labels:  activerecord
Dumb Passwords
Don't let your user be a victim of their own action
Stars: ✭ 77 (-25.24%)
Mutual labels:  validations
Torm
Just another simple PHP ORM. You can use it, but don't ask me why I made it. :-)
Stars: ✭ 90 (-12.62%)
Mutual labels:  activerecord
Vee Validate
✅ Form Validation for Vue.js
Stars: ✭ 8,820 (+8463.11%)
Mutual labels:  validations
Activerecord Clean Db Structure
Automatic cleanup for the Rails db/structure.sql file (ActiveRecord/PostgreSQL)
Stars: ✭ 101 (-1.94%)
Mutual labels:  activerecord
Validates timeliness
Date and time validation plugin for ActiveModel and Rails. Supports multiple ORMs and allows custom date/time formats.
Stars: ✭ 1,319 (+1180.58%)
Mutual labels:  activerecord
Sequel Activerecord connection
Allows Sequel to reuse an ActiveRecord connection
Stars: ✭ 84 (-18.45%)
Mutual labels:  activerecord
Ar Linkmany
ActiveRecord behavior for saving many-to-many relations
Stars: ✭ 83 (-19.42%)
Mutual labels:  activerecord
Fluent Plugin Sql
SQL input/output plugin for Fluentd
Stars: ✭ 82 (-20.39%)
Mutual labels:  activerecord
Smart sms
The easiest way to integrate SMS service in China
Stars: ✭ 92 (-10.68%)
Mutual labels:  activerecord
Acts as hashids
Use Youtube-Like ID in ActiveRecord seamlessly.
Stars: ✭ 76 (-26.21%)
Mutual labels:  activerecord
Active record Mti
ActiveRecord support for PostgreSQL's native inherited tables (multi-table inheritance)
Stars: ✭ 100 (-2.91%)
Mutual labels:  activerecord
Spreadsheet architect
Spreadsheet Architect is a library that allows you to create XLSX, ODS, or CSV spreadsheets super easily from ActiveRecord relations, plain Ruby objects, or tabular data.
Stars: ✭ 1,160 (+1026.21%)
Mutual labels:  activerecord
Active reporting
OLAP-like DSL for ActiveRecord-based reporting
Stars: ✭ 83 (-19.42%)
Mutual labels:  activerecord
Rails or
Cleaner syntax for writing OR Query in Rails 5, 6. And also add #or support to Rails 3 and 4.
Stars: ✭ 86 (-16.5%)
Mutual labels:  activerecord
Sails Hook Validation
Custom validation error messages for sails model with i18n support
Stars: ✭ 103 (+0%)
Mutual labels:  validations
Graphql devise
GraphQL interface on top devise_token_auth
Stars: ✭ 100 (-2.91%)
Mutual labels:  activerecord

Valle Build Status Code Climate Gem Version

Valle automatically creates validations for the minimum and maximum values of fields in your ActiveRecord model(s). No more worrying that string lengths or ID values will exceed the permissible DB limits!

For example, the maximum length of the string type in PostgreSQL is 255. Valle creates the following validator for you, so you no longer need to write it by hand:

validates :field_name, length: { maximum: 255 }

Note: If you do not do this (and usually you are) and try to enter 2147483648 into a field of type integer (see the Numeric types section of PostgreSQL docs), you will get a 500 error.

Example:

PG::Error: ERROR:  value "2147483648" is out of range for type integer
: SELECT  "users".* FROM "users"  WHERE "users"."id" = $1 LIMIT 1

Supported ActiveRecord field types

  • :primary_key
  • :integer
  • :string
  • :text

Installation

Add this line to your application's Gemfile:

gem 'valle'

And then execute:

$ bundle

Or install it yourself:

$ gem install valle

If you are using other framework than Rails (e.g. Sinatra), call Valle::Hooks.init method during the boot process.

Usage

By default, this gem adds validators to all your ActiveRecord models. If that is the behavior you want, you don't need to tweak it.

However, you can skip some of them by adding the file config/initializers/valle.rb containing:

Valle.configure do |config|
  config.exclude_models = %w(Post)
end

Also, you can disable it temporarily by setting the enabled configuration option to false.

Valle.configure do |config|
  config.enabled = false
end

Disabling Valle on specific attributes

There are cases where you need to skip validation for a particular attribute (see #4). For example, CarrierWave stores images temporarily in attributes, so calling save on them will fail because of its LengthValidator (255 characters maximum). You can disable Valle for such fields using the exclude_attributes configuration option:

Valle.configure do |config|
  config.exclude_attributes = {
    'User' => %w(image)
  }
end

Alternatives

There is a similar gem, called validates_lengths_from_database. It solves only one part of the problem — applicable to strings. Valle, however, is designed to work with all possible field types.

Developing

Docker container

If you have docker installed on your machine, you can spin up a sandbox and run test suite in a few seconds:

$ docker build -t valle .
$ docker run -it --rm -v "$PWD":/usr/src/lib valle bundle exec rake

Or simply use Makefile commands:

$ make docker_build
$ make docker_test

Debugging Cucumber tests

Uncomment @announce-output tag at the top of the .feature file.

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Added some feature')
  4. Run test suite (rake test_suite)
  5. Push to the branch (git push origin my-new-feature)
  6. Create new Pull Request

Credits

Original authors:

Thank you to all our amazing contributors!

License

Valle is released under the MIT License.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].