Skip to content

Commit 5a5c04e

Browse files
committed
Released version 5.1.1
1 parent ae2f4e9 commit 5a5c04e

9 files changed

+335
-377
lines changed

HISTORY.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
https://github.com/josdejong/jsoneditor
44

55

6-
## not yet released, version 5.1.1
6+
## 2016-01-16, version 5.1.1
77

88
- Fixed #257: Improving error messages for enum errors failed when the
99
schema contains references.

dist/jsoneditor-minimalist.js

+15-36
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424
* Copyright (c) 2011-2016 Jos de Jong, http://jsoneditoronline.org
2525
*
2626
* @author Jos de Jong, <[email protected]>
27-
* @version 5.1.0
28-
* @date 2016-01-14
27+
* @version 5.1.1
28+
* @date 2016-01-16
2929
*/
3030
(function webpackUniversalModuleDefinition(root, factory) {
3131
if(typeof exports === 'object' && typeof module === 'object')
@@ -162,7 +162,7 @@ return /******/ (function(modules) { // webpackBootstrap
162162
'ace', 'theme',
163163
'ajv', 'schema',
164164
'onChange', 'onEditable', 'onError', 'onModeChange',
165-
'escapeUnicode', 'history', 'mode', 'modes', 'name', 'indentation'
165+
'escapeUnicode', 'history', 'search', 'mode', 'modes', 'name', 'indentation'
166166
];
167167

168168
Object.keys(options).forEach(function (option) {
@@ -361,7 +361,7 @@ return /******/ (function(modules) { // webpackBootstrap
361361
var ajv;
362362
try {
363363
// grab ajv from options if provided, else create a new instance
364-
ajv = this.options.ajv || Ajv({ allErrors: true });
364+
ajv = this.options.ajv || Ajv({ allErrors: true, verbose: true });
365365

366366
}
367367
catch (err) {
@@ -607,7 +607,9 @@ return /******/ (function(modules) { // webpackBootstrap
607607
}
608608

609609
// clear search
610-
this.searchBox.clear();
610+
if (this.searchBox) {
611+
this.searchBox.clear();
612+
}
611613
};
612614

613615
/**
@@ -832,12 +834,10 @@ return /******/ (function(modules) { // webpackBootstrap
832834
if (this.validateSchema) {
833835
var valid = this.validateSchema(root.getValue());
834836
if (!valid) {
835-
var schema = this.options.schema;
836-
837837
// apply all new errors
838838
schemaErrors = this.validateSchema.errors
839839
.map(function (error) {
840-
return util.improveSchemaError(schema, error);
840+
return util.improveSchemaError(error);
841841
})
842842
.map(function findNode (error) {
843843
return {
@@ -1611,6 +1611,7 @@ return /******/ (function(modules) { // webpackBootstrap
16111611
}
16121612
];
16131613

1614+
16141615
/***/ },
16151616
/* 2 */
16161617
/***/ function(module, exports, __webpack_require__) {
@@ -2022,11 +2023,9 @@ return /******/ (function(modules) { // webpackBootstrap
20222023
if (doValidate && this.validateSchema) {
20232024
var valid = this.validateSchema(json);
20242025
if (!valid) {
2025-
var schema = this.options.schema;
2026-
errors = this.validateSchema.errors
2027-
.map(function (error) {
2028-
return util.improveSchemaError(schema, error);
2029-
});
2026+
errors = this.validateSchema.errors.map(function (error) {
2027+
return util.improveSchemaError(error);
2028+
});
20302029
}
20312030
}
20322031

@@ -2755,34 +2754,14 @@ return /******/ (function(modules) { // webpackBootstrap
27552754
return [prop].concat(parsePath(remainder))
27562755
};
27572756

2758-
/**
2759-
* Retrieve a part of the schema
2760-
* @param {Object} schema
2761-
* @param {string} schemaPath A path like "#/properties/gender/enum"
2762-
* @return {Object} Returns the found part of the schema, or undefined when not found.
2763-
*/
2764-
exports.getFromSchema = function (schema, schemaPath) {
2765-
var path = schemaPath.split('/');
2766-
path.shift(); // remove the first #
2767-
2768-
var obj = schema;
2769-
var prop;
2770-
while (prop = path.shift()) {
2771-
obj = obj[prop];
2772-
}
2773-
2774-
return obj;
2775-
};
2776-
27772757
/**
27782758
* Improve the error message of a JSON schema error
2779-
* @param {Object} schema
27802759
* @param {Object} error
27812760
* @return {Object} The error
27822761
*/
2783-
exports.improveSchemaError = function (schema, error) {
2784-
if (error.keyword === 'enum') {
2785-
var enums = exports.getFromSchema(schema, error.schemaPath);
2762+
exports.improveSchemaError = function (error) {
2763+
if (error.keyword === 'enum' && Array.isArray(error.schema)) {
2764+
var enums = error.schema;
27862765
if (enums) {
27872766
enums = enums.map(function (value) {
27882767
return JSON.stringify(value);

dist/jsoneditor-minimalist.map

+1-1
Large diffs are not rendered by default.

dist/jsoneditor-minimalist.min.js

+6-6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)