Commit 10aa38c5 authored by Boris Kocherov's avatar Boris Kocherov

tv4: add support propertyNames

parent 16494021
......@@ -1059,6 +1059,11 @@ ValidatorContext.prototype.validateObjectProperties = function validateObjectPro
for (var key in data) {
var keyPointerPath = dataPointerPath + "/" + key.replace(/~/g, '~0').replace(/\//g, '~1');
var foundMatch = false;
if (schema.propertyNames !== undefined && schema.propertyNames !== true) {
if (error = this.validateAllValidators(key, schema.propertyNames, keyPointerPath)) {
return this.createError(ErrorCodes.OBJECT_PROPERTY_NAMES, {key: key, error: error.message}, '', '/propertyNames', null, data, schema).prefixWith(key, null);
}
}
if (schema.properties !== undefined && schema.properties[key] !== undefined) {
foundMatch = true;
if (error = this.validateAll(data[key], schema.properties[key], [key], ["properties", key], keyPointerPath)) {
......@@ -1447,6 +1452,7 @@ var ErrorCodes = {
OBJECT_REQUIRED: 302,
OBJECT_ADDITIONAL_PROPERTIES: 303,
OBJECT_DEPENDENCY_KEY: 304,
OBJECT_PROPERTY_NAMES: 305,
// Array errors
ARRAY_LENGTH_SHORT: 400,
ARRAY_LENGTH_LONG: 401,
......@@ -1491,6 +1497,7 @@ var ErrorMessagesDefault = {
OBJECT_REQUIRED: "Missing required property: {key}",
OBJECT_ADDITIONAL_PROPERTIES: "Additional properties not allowed",
OBJECT_DEPENDENCY_KEY: "Dependency failed - key must exist: {missing} (due to key: {key})",
OBJECT_PROPERTY_NAMES: "Property name \"{key}\" does not match schema with error: {error}",
// Array errors
ARRAY_LENGTH_SHORT: "Array is too short ({length}), minimum {minimum}",
ARRAY_LENGTH_LONG: "Array is too long ({length}), maximum {maximum}",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment