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