Sha256: 0dbcd4dc48346026abf6c7be32f912c2849c6977749e3dc12e781f43639abc6d

Contents?: true

Size: 309 Bytes

Versions: 2

Compression:

Stored size: 309 Bytes

Contents

class Base64Validator < ActiveModel::EachValidator

  def validate_each(record, attribute, value)
    unless value =~ /^(?:[A-Za-z0-9+$]{4})*(?:[A-Za-z0-9+$]{2}==|[A-Za-z0-9+$]{3}=|[A-Za-z0-9+$]{4})$/
      record.errors[attribute] << (options[:message] || I18n.t('errors.messages.base64'))
    end
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
flash_validators-3.0.1 lib/flash_validators/validators/base64_validator.rb
flash_validators-3.0.0 lib/flash_validators/validators/base64_validator.rb