Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Ticket #2705 (closed defect: fixed)

Opened 5 years ago

Last modified 5 years ago

validates_presence_of confounds 0 with no value

Reported by: anonymous Assigned to: David
Priority: normal Milestone:
Component: ActionPack Version: 0.14.1
Severity: normal Keywords: validates_presence_of blank?
Cc:

Description

validates_presence_of considers 0 to be not present. This is because it relies on #blank? to check and as it happens 0.blank? == true.

Now there are cases where users have to entered values different from 0, but to check this is not the business of validates_presence_of; there are other validations for this task, such as validates_inclusion_of. As it stands, there is no validation for checking that the user has entered any value whatsoever.

See also #2518

Change History

11/02/05 15:38:02 changed by bitsweat

  • status changed from new to closed.
  • resolution set to fixed.

(In [2849]) Changed 0.blank? to false rather than true since it violates everyone's expectation of blankness. Closes #2518, Closes #2705.