Sha256: b3e7b821f03319df4043ee60e5c4878e53116415eca6d2f9077a65c485374782
Contents?: true
Size: 377 Bytes
Versions: 1
Compression:
Stored size: 377 Bytes
Contents
require 'active_model' class GeojsonValidator < ActiveModel::EachValidator def validate_each(record, attribute, value) unless valid_geojson?(value) message = options[:message] || "invalid" record.errors.add(attribute, message) end end private # @return [Boolean] def valid_geojson?(geojson) Geojsonlint.validate(geojson).valid? end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
geojsonlint-0.1.2 | lib/geojsonlint/geojson_validator.rb |