Sha256: 1bf645b10dd9405c734242c161c84ed968218ad95d8cf0917184e4e01b498c8f
Contents?: true
Size: 375 Bytes
Versions: 285
Compression:
Stored size: 375 Bytes
Contents
# An ActiveRecord validator for any url field that you would use with effective_url or otherwise # # validates :website, url: true class UrlValidator < ActiveModel::EachValidator PATTERN = /\Ahttps?:\/\/\w+.+\Z/ def validate_each(record, attribute, value) if value.present? record.errors.add(attribute, 'is invalid') unless PATTERN =~ value end end end
Version data entries
285 entries across 285 versions & 1 rubygems