MCPcopy Create free account
hub / github.com/json-editor/json-editor / _validateSchema

Method _validateSchema

src/validator.js:698–748  ·  view source on GitHub ↗
(schema, value, path)

Source from the content-addressed store, hash-verified

696 }
697
698 _validateSchema (schema, value, path) {
699 const errors = []
700 path = path || this.jsoneditor.root.formname
701
702 /* Work on a copy of the schema */
703 schema = extend({}, this.jsoneditor.expandRefs(schema))
704
705 /*
706 * Type Agnostic Validation
707 */
708 /* Version 3 `required` and `required_by_default` */
709 if (typeof value === 'undefined') {
710 return this._validateV3Required(schema, value, path)
711 }
712
713 Object.keys(schema).forEach(key => {
714 if (this._validateSubSchema[key]) {
715 errors.push(...this._validateSubSchema[key].call(this, schema, value, path))
716 }
717 })
718
719 /*
720 * Type Specific Validation
721 */
722 errors.push(...this._validateByValueType(schema, value, path))
723
724 if (schema.links) {
725 schema.links.forEach((s, m) => {
726 if (s.rel && s.rel.toLowerCase() === 'describedby') {
727 schema = this._expandSchemaLink(schema, m)
728 errors.push(...this._validateSchema(schema, value, path, this.translate))
729 }
730 })
731 }
732
733 /* date, time and datetime-local validation */
734 if (['date', 'time', 'datetime-local'].includes(schema.format)) {
735 errors.push(...this._validateDateTimeSubSchema(schema, value, path))
736 }
737
738 /* uuid validation */
739 if (['uuid'].includes(schema.format)) {
740 errors.push(...this._validateUUIDSchema(schema, value, path))
741 }
742
743 /* custom validator */
744 errors.push(...this._validateCustomValidator(schema, value, path))
745
746 /* Remove duplicate errors and add "errorcount" property */
747 return this._removeDuplicateErrors(errors)
748 }
749
750 _expandSchemaLink (schema, m) {
751 const href = schema.links[m].href

Callers 14

dependentSchemasMethod · 0.95
containsMethod · 0.95
ifMethod · 0.95
validateMethod · 0.95
anyOfMethod · 0.95
oneOfMethod · 0.95
notMethod · 0.95
itemsMethod · 0.95
propertiesMethod · 0.95
patternPropertiesMethod · 0.95
additionalPropertiesMethod · 0.95
dependenciesMethod · 0.95

Calls 9

_validateV3RequiredMethod · 0.95
_validateByValueTypeMethod · 0.95
_expandSchemaLinkMethod · 0.95
_validateUUIDSchemaMethod · 0.95
extendFunction · 0.90
expandRefsMethod · 0.80

Tested by

no test coverage detected