Sha256: 7ac301fab7348afeef9703ceb5d3047f98b401969e3bbcbdd77bba0180beeae5

Contents?: true

Size: 229 Bytes

Versions: 54

Compression:

Stored size: 229 Bytes

Contents

class AsciiOnlyValidator < ActiveModel::EachValidator
  def validate_each(record, attribute, value)
    value.encode(Encoding::ASCII)
  rescue Encoding::UndefinedConversionError
    record.errors.add(attribute, :ascii)
  end
end

Version data entries

54 entries across 54 versions & 1 rubygems

Version Path
shipit-engine-0.29.0 app/validators/ascii_only_validator.rb
shipit-engine-0.28.1 app/validators/ascii_only_validator.rb
shipit-engine-0.28.0 app/validators/ascii_only_validator.rb
shipit-engine-0.27.1 app/validators/ascii_only_validator.rb
shipit-engine-0.27.0 app/validators/ascii_only_validator.rb
shipit-engine-0.26.0 app/validators/ascii_only_validator.rb
shipit-engine-0.25.1 app/validators/ascii_only_validator.rb
shipit-engine-0.25.0 app/validators/ascii_only_validator.rb
shipit-engine-0.24.0 app/validators/ascii_only_validator.rb
shipit-engine-0.23.1 app/validators/ascii_only_validator.rb
shipit-engine-0.23.0 app/validators/ascii_only_validator.rb
shipit-engine-0.22.0 app/validators/ascii_only_validator.rb
shipit-engine-0.21.0 app/validators/ascii_only_validator.rb
shipit-engine-0.20.1 app/validators/ascii_only_validator.rb
shipit-engine-0.20.0 app/validators/ascii_only_validator.rb
shipit-engine-0.19.0 app/validators/ascii_only_validator.rb
shipit-engine-0.18.1 app/validators/ascii_only_validator.rb
shipit-engine-0.18.0 app/validators/ascii_only_validator.rb
shipit-engine-0.17.0 app/validators/ascii_only_validator.rb
shipit-engine-0.16.0 app/validators/ascii_only_validator.rb