Sha256: fcb4a17f0eb84c4e7eb5bee12c76e5bf8c7a7563e6307cb59159ec6578ee52ef

Contents?: true

Size: 284 Bytes

Versions: 23

Compression:

Stored size: 284 Bytes

Contents

# frozen_string_literal: true

class StyleValidator < ActiveModel::EachValidator
  def validate_each(record, attribute, value)
    return if value.in?(valid_styles = record.class::STYLES)

    record.errors.add(attribute, :inclusion, valid_styles: valid_styles.to_sentence)
  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
bs5-0.0.31 app/validators/style_validator.rb
bs5-0.0.30 app/validators/style_validator.rb
bs5-0.0.29 app/validators/style_validator.rb
bs5-0.0.28 app/validators/style_validator.rb
bs5-0.0.27 app/validators/style_validator.rb
bs5-0.0.26 app/validators/style_validator.rb
bs5-0.0.25 app/validators/style_validator.rb
bs5-0.0.24 app/validators/style_validator.rb
bs5-0.0.23 app/validators/style_validator.rb
bs5-0.0.22 app/validators/style_validator.rb
bs5-0.0.21 app/validators/style_validator.rb
bs5-0.0.20 app/validators/style_validator.rb
bs5-0.0.19 app/validators/style_validator.rb
bs5-0.0.18 app/validators/style_validator.rb
bs5-0.0.17 app/validators/style_validator.rb
bs5-0.0.16 app/validators/style_validator.rb
bs5-0.0.15 app/validators/style_validator.rb
bs5-0.0.14 app/validators/style_validator.rb
bs5-0.0.13 app/validators/style_validator.rb
bs5-0.0.12 app/validators/style_validator.rb