Sha256: 04505e5d9798defc4162466e1d28c786a78ea69b96483e6ac21a8b31a6b8cca4
Contents?: true
Size: 385 Bytes
Versions: 9
Compression:
Stored size: 385 Bytes
Contents
class TagIdValidator < ActiveModel::Validator def validate(record) unless valid_tag_id?(record.tag_id) record.errors[:tag_id] << "ID must be valid in a URL and have no more than one slash" end end private def valid_tag_id?(tag_id) tag_id.to_s.match(/\A[a-z0-9\-\/]+\Z/) && tag_id.to_s.count('/') <= 1 && ! tag_id.to_s.end_with?('/') end end
Version data entries
9 entries across 9 versions & 1 rubygems