You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Aug 9, 2024. It is now read-only.
Apologies in advance if I am making a mistake, but I was having some trouble following the validation block example from the repo readme. I think perhaps the example has a minor typo?
validates:first_namedo |object,name,value|
object.errors[name] << "must be over 4 chars long"ifvalue.length <= 4
After digging into the library code a bit I was able to get things working by accessing the @errors hash as object._errors. For example, in my code:
validates:domaindo |object,name,value|
regex=/^www\.[a-z]+\.com$/message='domain must be formatted like www.domain.com'object._errors[name] << messageunlessvalue =~ regexend
The hash returned by the object.errors accessor was not initialized properly if a validation block was the first error reached but seemed to work fine if there was another validation clause failing.
Also want to say - Really happy I found this gem. Has been working great for what I'm trying to do using an existing python flask-restless API as a data service for my Rails front end. ActiveResource was not easy to get working and other gems didn't have the nice ActiveRecord-like features. Thanks so much!