diff --git a/Makefile b/Makefile
index 109706bda..e46ea0a98 100644
--- a/Makefile
+++ b/Makefile
@@ -49,8 +49,7 @@ MODULE_TARGETS = \
js/lib/id/ui/index.js \
js/lib/id/ui/core.js \
js/lib/id/ui/intro.js \
- js/lib/id/ui/preset.js \
- js/lib/id/validations.js
+ js/lib/id/ui/preset.js
js/lib/id/index.js: $(shell find modules/index.js -type f)
@rm -f $@
@@ -84,10 +83,6 @@ js/lib/id/ui/preset.js: $(shell find modules/ui/preset -type f)
@rm -f $@
node_modules/.bin/rollup -f umd -n iD.ui.preset modules/ui/preset/index.js --no-strict -o $@
-js/lib/id/validations.js: $(shell find modules/validations -type f)
- @rm -f $@
- node_modules/.bin/rollup -f umd -n iD.validations modules/validations/index.js --no-strict -o $@
-
dist/iD.js: \
js/lib/bootstrap-tooltip.js \
js/lib/d3.v3.js \
diff --git a/index.html b/index.html
index 6ede12354..0653b3571 100644
--- a/index.html
+++ b/index.html
@@ -45,8 +45,6 @@
-
-
diff --git a/js/lib/id/index.js b/js/lib/id/index.js
index 597dec459..2321b214b 100644
--- a/js/lib/id/index.js
+++ b/js/lib/id/index.js
@@ -12840,6 +12840,122 @@
presets: presets$1
});
+ function DeprecatedTag() {
+
+ var validation = function(changes) {
+ var warnings = [];
+ for (var i = 0; i < changes.created.length; i++) {
+ var change = changes.created[i],
+ deprecatedTags = change.deprecatedTags();
+
+ if (!_.isEmpty(deprecatedTags)) {
+ var tags = tagText({ tags: deprecatedTags });
+ warnings.push({
+ id: 'deprecated_tags',
+ message: t('validations.deprecated_tags', { tags: tags }),
+ entity: change
+ });
+ }
+ }
+ return warnings;
+ };
+
+ return validation;
+ }
+
+ function ManyDeletions() {
+ var threshold = 100;
+
+ var validation = function(changes) {
+ var warnings = [];
+ if (changes.deleted.length > threshold) {
+ warnings.push({
+ id: 'many_deletions',
+ message: t('validations.many_deletions', { n: changes.deleted.length })
+ });
+ }
+ return warnings;
+ };
+
+ return validation;
+ }
+
+ function MissingTag() {
+
+ // Slightly stricter check than Entity#isUsed (#3091)
+ function hasTags(entity, graph) {
+ return _.without(Object.keys(entity.tags), 'area', 'name').length > 0 ||
+ graph.parentRelations(entity).length > 0;
+ }
+
+ var validation = function(changes, graph) {
+ var warnings = [];
+ for (var i = 0; i < changes.created.length; i++) {
+ var change = changes.created[i],
+ geometry = change.geometry(graph);
+
+ if ((geometry === 'point' || geometry === 'line' || geometry === 'area') && !hasTags(change, graph)) {
+ warnings.push({
+ id: 'missing_tag',
+ message: t('validations.untagged_' + geometry),
+ tooltip: t('validations.untagged_' + geometry + '_tooltip'),
+ entity: change
+ });
+ }
+ }
+ return warnings;
+ };
+
+ return validation;
+ }
+
+ function TagSuggestsArea() {
+
+ // https://github.com/openstreetmap/josm/blob/mirror/src/org/
+ // openstreetmap/josm/data/validation/tests/UnclosedWays.java#L80
+ function tagSuggestsArea(tags) {
+ if (_.isEmpty(tags)) return false;
+
+ var presence = ['landuse', 'amenities', 'tourism', 'shop'];
+ for (var i = 0; i < presence.length; i++) {
+ if (tags[presence[i]] !== undefined) {
+ return presence[i] + '=' + tags[presence[i]];
+ }
+ }
+
+ if (tags.building && tags.building === 'yes') return 'building=yes';
+ }
+
+ var validation = function(changes, graph) {
+ var warnings = [];
+ for (var i = 0; i < changes.created.length; i++) {
+ var change = changes.created[i],
+ geometry = change.geometry(graph),
+ suggestion = (geometry === 'line' ? tagSuggestsArea(change.tags) : undefined);
+
+ if (suggestion) {
+ warnings.push({
+ id: 'tag_suggests_area',
+ message: t('validations.tag_suggests_area', { tag: suggestion }),
+ entity: change
+ });
+ }
+ }
+ return warnings;
+ };
+
+ return validation;
+ }
+
+
+
+ var validations = Object.freeze({
+ DeprecatedTag: DeprecatedTag,
+ ManyDeletions: ManyDeletions,
+ MissingTag: MissingTag,
+ TagSuggestsArea: TagSuggestsArea
+ });
+
exports.actions = actions;
exports.geo = geo;
exports.svg = svg;
@@ -12860,7 +12976,11 @@
exports.presets = presets;
>>>>>>> ed34eb3... external modules for presets
exports.util = util;
+<<<<<<< HEAD
>>>>>>> 42ce4cf... external modules for util
+=======
+ exports.validations = validations;
+>>>>>>> 44cf7f1... Add external modules to validations
exports.Connection = Connection;
exports.Difference = Difference;
exports.Entity = Entity;
diff --git a/modules/index.js b/modules/index.js
index cf07941f0..a677045b7 100644
--- a/modules/index.js
+++ b/modules/index.js
@@ -5,6 +5,7 @@ import * as modes from './modes/index';
import * as util from './util/index';
import * as operations from './operations/index';
import * as presets from './presets/index';
+import * as validations from './validations/index';
export { Connection } from './core/connection';
export { Difference } from './core/difference';
@@ -24,5 +25,6 @@ export {
modes,
operations,
presets,
- util
+ util,
+ validations
};
diff --git a/modules/validations/deprecated_tag.js b/modules/validations/deprecated_tag.js
index d9ff27c45..72337b3a9 100644
--- a/modules/validations/deprecated_tag.js
+++ b/modules/validations/deprecated_tag.js
@@ -1,3 +1,4 @@
+import { tagText } from '../util/index';
export function DeprecatedTag() {
var validation = function(changes) {
@@ -7,7 +8,7 @@ export function DeprecatedTag() {
deprecatedTags = change.deprecatedTags();
if (!_.isEmpty(deprecatedTags)) {
- var tags = iD.util.tagText({ tags: deprecatedTags });
+ var tags = tagText({ tags: deprecatedTags });
warnings.push({
id: 'deprecated_tags',
message: t('validations.deprecated_tags', { tags: tags }),
diff --git a/test/index.html b/test/index.html
index e371d79e0..4a28191b8 100644
--- a/test/index.html
+++ b/test/index.html
@@ -49,7 +49,6 @@
-