Sha256: 8bcac3741fe41814cd6aa58611aefc9dcc94a1b5f9524fb92df57c0ce8c78b21
Contents?: true
Size: 602 Bytes
Versions: 4
Compression:
Stored size: 602 Bytes
Contents
module OmgValidator module Validators # Checks whether input only contains alpha-numberic characters and dashes # # validates :perma_link, alpha_dash: true class AlphaDashValidator < ActiveModel::EachValidator def validate_each(record, attribute, value) return nil if value.nil? reg = /^([-a-z0-9_-])+$/i unless reg.match(value) record.errors[attribute] = "must contain only alpha-numeric characters and dashes" end end end end end ActiveModel::Validations::AlphaDashValidator = OmgValidator::Validators::AlphaDashValidator
Version data entries
4 entries across 4 versions & 1 rubygems