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

Method if

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

Source from the content-addressed store, hash-verified

98 return errors
99 },
100 if (schema, value, path) {
101 if (typeof schema.then === 'undefined' && typeof schema.else === 'undefined') {
102 return []
103 }
104
105 const ifErrors = this._validateSchema(schema.if, value, path)
106 let thenErrors = []
107 let elseErrors = []
108
109 if (typeof schema.then !== 'undefined') {
110 thenErrors = this._validateSchema(schema.then, value, path)
111 }
112
113 if (typeof schema.else !== 'undefined') {
114 elseErrors = this._validateSchema(schema.else, value, path)
115 }
116
117 if (schema.if === true) {
118 return thenErrors
119 }
120
121 if (schema.if === false) {
122 return elseErrors
123 }
124
125 if (ifErrors.length === 0) {
126 return thenErrors
127 }
128
129 if (ifErrors.length > 0) {
130 return elseErrors
131 }
132
133 return []
134 },
135 const (schema, value, path) {
136 const valid = JSON.stringify(schema.const) === JSON.stringify(value)
137

Callers

nothing calls this directly

Calls 1

_validateSchemaMethod · 0.95

Tested by

no test coverage detected