Sha256: cfdda636d349556bb0e054a15a8d4cad72e4f0c98bcea97dd1b31ad374b60b96
Contents?: true
Size: 1.08 KB
Versions: 18
Compression:
Stored size: 1.08 KB
Contents
class ValidationHelperCollection def slug_regex /\A[-_a-zA-Z0-9]+\z/ end def email_regex /\A\s*(([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})[\s\/,;]*)+\z/ end def url_regex /\A(https?:\/\/)/ end def zip_regex /\A(\d{5})?\z/ end def youtube_regex /[a-zA-Z0-9_-]{11}/ end ### Complete Hash Validations def slug { uniqueness: true, presence: true, format: { with: self.slug_regex, message: 'cannot have spaces or special characters' } } end def email { allow_blank: true, format: { with: self.email_regex, message: 'is invalid' } } end def url { allow_blank: true, format: { with: self.url_regex, message: 'is invalid' } } end def zip { allow_blank: true, format: { with: self.zip_regex, message: 'is invalid' } } end def youtube_url { allow_blank: true, format: { with: self.youtube_regex, message: 'is invalid' } } end end
Version data entries
18 entries across 18 versions & 2 rubygems