class Typero::LabelType

Public Instance Methods

db_schema() click to toggle source
# File lib/typero/type/types/label_type.rb, line 15
def db_schema
  [:string, {
    limit: 30
  }]
end
set() click to toggle source
# File lib/typero/type/types/label_type.rb, line 2
def set
  value do |data|
    data
      .to_s
      .gsub(/\s+/,'-')
      .gsub(/[^\w\-]/,'')
      .gsub(/\-+/, '-')[0,30]
      .downcase
  end

  error_for(:unallowed_characters_error) unless value =~ /^[\w\-]+$/
end