mirror of
https://github.com/ditkrg/validates_timeliness.git
synced 2026-01-24 23:06:42 +00:00
show restriction errors in Rails test mode by default.
or always if not using Rails
This commit is contained in:
parent
048bf3ba6c
commit
81030a6ed8
14
README.rdoc
14
README.rdoc
@ -128,20 +128,16 @@ The value should be an array of 3 values being year, month and day in that order
|
|||||||
=== TEMPORAL RESTRICTION ERRORS:
|
=== TEMPORAL RESTRICTION ERRORS:
|
||||||
|
|
||||||
When using the validation temporal restrictions there are times when the restriction
|
When using the validation temporal restrictions there are times when the restriction
|
||||||
value itself may be invalid. Normally this will add an error to the model such as
|
option value itself may be invalid. This will add an error to the model such as
|
||||||
'restriction :before value was invalid'. These can be annoying if you are using
|
'Error occurred validating birth_date for :before restriction'. These can be annoying
|
||||||
procs or methods as restrictions and don't care if they don't evaluate properly
|
in development or production as you most likely just want to skip the option if no
|
||||||
and you want the validation to complete. In these situations you turn them off.
|
valid value was returned. By default these errors are displayed in Rails test mode.
|
||||||
|
|
||||||
To turn them off:
|
To turn them on/off:
|
||||||
|
|
||||||
# in the setup block
|
# in the setup block
|
||||||
config.ignore_restriction_errors = true
|
config.ignore_restriction_errors = true
|
||||||
|
|
||||||
A word of warning though, as this may hide issues with the model and make those
|
|
||||||
corner cases a little harder to test. In general if you are using procs or
|
|
||||||
model methods and you only care when they return a value, then they should
|
|
||||||
return nil in all other situations. Restrictions are skipped if they are nil.
|
|
||||||
|
|
||||||
=== DISPLAY INVALID VALUES IN DATE/TIME SELECT HELPERS:
|
=== DISPLAY INVALID VALUES IN DATE/TIME SELECT HELPERS:
|
||||||
|
|
||||||
|
|||||||
@ -24,7 +24,7 @@ module ValidatesTimeliness
|
|||||||
|
|
||||||
# Ignore errors when restriction options are evaluated
|
# Ignore errors when restriction options are evaluated
|
||||||
mattr_accessor :ignore_restriction_errors
|
mattr_accessor :ignore_restriction_errors
|
||||||
@@ignore_restriction_errors = false
|
@@ignore_restriction_errors = defined?(Rails) ? !Rails.env.test? : false
|
||||||
|
|
||||||
# Setup method for plugin configuration
|
# Setup method for plugin configuration
|
||||||
def self.setup
|
def self.setup
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user