No commit activity in last 3 years
No release in over 3 years
Only add a error messages for one model attribute if this error message not exists for the model attribute
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.0
~> 2.0.1
~> 2.8.0

Runtime

 Project Readme

activemodel_unique_error

Build Status Gem Version

Only add a error messages for one model attribute if this error message not exists for the model attribute

Installation

Add this line to your application's Gemfile:

gem 'activemodel_unique_errors'

And then execute:

$ bundle

Or install it yourself as:

$ gem install activemodel_unique_errors

Usage

user = User.new
user.errors.size # 0

msg = 'This error text must be uniq!'
user.errors.add(:login, msg)
user.errors.add(:login, msg)
user.errors[:login]= msg


user.errors[:login] # ['Login This error text must be uniq!'] - only one unique error for this attribute and message 
user.errors.size # 1

user.errors.add(:login, 'New error message')
user.errors[:login] # ['Login This error text must be uniq!', 'Login New error message'] 
user.errors.size # 2

Copyright

Copyright (c) 2014 soeren mothes. See LICENSE.txt for further details.