No commit activity in last 3 years
No release in over 3 years
Basic error messages for Scrivener filters
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Development

~> 1.2
~> 0.2
 Project Readme

Scrivener Errors

Basic error messages for Scrivener filters.

Description

Scrivener errors are returned as a hash with a format like:

{:email => [:not_email], :password => [:not_present]}

This can be represented instead as a string like:

Email is not an email, password can't be blank

ScrivenerErrors will present these error hashes as a string or list of error messages for use in failure notices or form errors.

This also comes with a small plugin for Cuba to get the error message easily, ScrivenerErrors::Helpers.

Installation

$ gem install scrivener_errors

Usage

# Setup the plugin for Cuba
require "scrivener_errors"
Cuba.plugin ScrivenerErrors::Helpers

# Inside a Cuba action
filter = Signup.new(req.params)
if !filter.valid?
  session[:error] = filter_error(filter)
  res.redirect "/some_form"
end

You can also get a string of comma joined errors for a specific attribute. It does not include the attribute name in this case.

scrivener_errors[:email] # => "is too short, is not an email"

Notes

Currently there's no I18n in use. The error messages are from a small English mapped hash at the moment.

An error type that is not found will be represented like "Password is invalid" by default.