Skip to content

Handle when the passed value is not a Date value. when it's a Numeric #230

@eng-Abdurhman

Description

@eng-Abdurhman

When the passed value is not a date. when it is a Numeric, then we get the following exception 👇
=> NoMethodError: undefined method "to_date" for 444:Integer


Example:
# app/models/item.rb

validates_date :expire_date

# console:

> item = Item.new(expire_date: 444)
> item.valid?
NoMethodError: undefined method `to_date' for 444:Integer

Can anyone help with this?


The suggested fix to handle Numeric values is: #229

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions