app/models/document/bbox_validator.rb in geoblacklight_admin-0.0.1 vs app/models/document/bbox_validator.rb in geoblacklight_admin-0.1.0

- old
+ new

@@ -12,11 +12,14 @@ def validate(record) # Assume true for empty values valid_geom = true # Sane for W,S,E,N? - proper_bounding_box(record, valid_geom) unless record.send(GeoblacklightAdmin::Schema.instance.solr_fields[:bounding_box]).nil? + unless record.send(GeoblacklightAdmin::Schema.instance.solr_fields[:bounding_box]).nil? + proper_bounding_box(record, + valid_geom) + end valid_geom end def proper_bounding_box(record, valid_geom) @@ -55,13 +58,14 @@ end # Reject ENVELOPE(-118.00.0000,-88.00.0000,51.00.0000,42.00.0000 # - Double period float-ish things? geom.each do |val| - if val.count(".") >= 2 - valid_geom = false - record.errors.add(GeoblacklightAdmin::Schema.instance.solr_fields[:bounding_box], "invalid ENVELOPE(W,E,N,S) syntax - found multiple periods in a coordinate value.") - end + next unless val.count(".") >= 2 + + valid_geom = false + record.errors.add(GeoblacklightAdmin::Schema.instance.solr_fields[:bounding_box], + "invalid ENVELOPE(W,E,N,S) syntax - found multiple periods in a coordinate value.") end end valid_geom end