Sha256: ec2e75ec005f94ff996a00ac8f318ea6fee8339e937db91731f832128e6e4db8

Contents?: true

Size: 273 Bytes

Versions: 6

Compression:

Stored size: 273 Bytes

Contents

module Amalgam::Validator
	class Slug < ActiveModel::Validator
    def validate(record)
      slug_field = options[:field] || :slug
      unless record.send(slug_field) =~ /\A[0-9a-z\-_]+\z/
        record.errors.add(attribute, :invalid, options)
      end
    end
	end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
amalgam-2.1.4.1 lib/amalgam/validators/slug.rb
amalgam-2.1.4 lib/amalgam/validators/slug.rb
amalgam-2.1.3.1 lib/amalgam/validators/slug.rb
amalgam-2.1.3 lib/amalgam/validators/slug.rb
amalgam-2.1.2 lib/amalgam/validators/slug.rb
amalgam-2.1.1 lib/amalgam/validators/slug.rb