Browse Source

converted warnings to errors

pull/253/head
Stephen Hess 9 years ago
parent
commit
6c85e5892e
  1. 4
      sanitiser/_boundary_country.js
  2. 6
      test/unit/sanitiser/_boundary_country.js

4
sanitiser/_boundary_country.js

@ -12,11 +12,11 @@ function sanitize(raw, clean) {
var country = raw['boundary.country'];
if (!check.string(country)) {
messages.warnings.push('boundary.country is not a string');
messages.errors.push('boundary.country is not a string');
delete clean.boundary.country;
}
else if (!containsIsoCode(country.toUpperCase())) {
messages.warnings.push(country + ' is not a valid ISO2/ISO3 country code');
messages.errors.push(country + ' is not a valid ISO2/ISO3 country code');
delete clean.boundary.country;
}
else {

6
test/unit/sanitiser/_boundary_country.js

@ -26,7 +26,7 @@ module.exports.tests.sanitize_boundary_country = function(test, common) {
var clean = {};
var errorsAndWarnings = sanitize(raw, clean);
t.equals(clean.boundary.country, undefined, 'should be undefined');
t.deepEquals(errorsAndWarnings, { errors: [], warnings: ['boundary.country is not a string'] }, 'non-string country warning');
t.deepEquals(errorsAndWarnings, { errors: ['boundary.country is not a string'], warnings: [] }, 'non-string country warning');
t.end();
});
@ -53,7 +53,7 @@ module.exports.tests.sanitize_boundary_country = function(test, common) {
var clean = {};
var errorsAndWarnings = sanitize(raw, clean);
t.equals(clean.boundary.country, undefined, 'should be undefined');
t.deepEquals(errorsAndWarnings, { errors: [], warnings: ['zq is not a valid ISO2/ISO3 country code'] }, 'country not found warning`');
t.deepEquals(errorsAndWarnings, { errors: ['zq is not a valid ISO2/ISO3 country code'], warnings: [] }, 'country not found warning`');
t.end();
});
@ -62,7 +62,7 @@ module.exports.tests.sanitize_boundary_country = function(test, common) {
var clean = {};
var errorsAndWarnings = sanitize(raw, clean);
t.equals(clean.boundary.country, undefined, 'should be undefined');
t.deepEquals(errorsAndWarnings, { errors: [], warnings: ['zqx is not a valid ISO2/ISO3 country code'] }, 'country not found warning`');
t.deepEquals(errorsAndWarnings, { errors: ['zqx is not a valid ISO2/ISO3 country code'], warnings: [] }, 'country not found warning`');
t.end();
});

Loading…
Cancel
Save