This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# in the model | |
validates_with CoordinatesValidator, :fields => [:location] | |
# Error messaging needs improvement. Since this validator will only whine if someone is forging requests | |
# with invalid data, i'm leaving it as it is. | |
class CoordinatesValidator < ActiveModel::Validator | |
def validate(record) | |
if options[:fields].any? { |f| invalid_latlng?(record.send(f)) } |
NewerOlder