Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove constants validating code from style-spec #5885

Merged
merged 1 commit into from
Dec 18, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 1 addition & 14 deletions src/style-spec/validate/validate.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@

const ValidationError = require('../error/validation_error');
const getType = require('../util/get_type');
const extend = require('../util/extend');
const unbundle = require('../util/unbundle_jsonlint');
const {isExpression} = require('../expression');
Expand All @@ -14,6 +12,7 @@ const {isFunction} = require('../function');
// high level object that needs to be descended into deeper or a simple
// scalar value.
// - valueSpec: current spec being evaluated. Tracks value.
// - styleSpec: current full spec being evaluated.

module.exports = function validate(options) {

Expand Down Expand Up @@ -41,19 +40,7 @@ module.exports = function validate(options) {

const value = options.value;
const valueSpec = options.valueSpec;
const key = options.key;
const styleSpec = options.styleSpec;
const style = options.style;

if (getType(value) === 'string' && value[0] === '@') {
if (styleSpec.$version > 7) {
return [new ValidationError(key, value, 'constants have been deprecated as of v8')];
}
if (!(value in style.constants)) {
return [new ValidationError(key, value, 'constant "%s" not found', value)];
}
options = extend({}, options, { value: style.constants[value] });
}

if (valueSpec.function && isFunction(unbundle(value))) {
return validateFunction(options);
Expand Down