@jsonforms/core
Advanced tools
Comparing version 3.1.0-alpha.2 to 3.1.0-alpha.3
@@ -0,1 +1,6 @@ | ||
import { JsonSchema } from '../models'; | ||
export declare const getFirstPrimitiveProp: (schema: any) => string; | ||
/** | ||
* Tests whether the schema has an enum based on oneOf. | ||
*/ | ||
export declare const isOneOfEnumSchema: (schema: JsonSchema) => boolean; |
{ | ||
"name": "@jsonforms/core", | ||
"version": "3.1.0-alpha.2", | ||
"version": "3.1.0-alpha.3", | ||
"description": "Core module of JSON Forms", | ||
@@ -102,3 +102,3 @@ "repository": "https://github.com/eclipsesource/jsonforms", | ||
}, | ||
"gitHead": "1e1ccad5f7ebfaf80412c8af3e422faebb12d0d5" | ||
"gitHead": "f8ea38f9f9dd3d46cbfde269ec43e9eb1632e428" | ||
} |
@@ -48,3 +48,3 @@ /* | ||
} from '../actions'; | ||
import { createAjv, Reducer } from '../util'; | ||
import { createAjv, isOneOfEnumSchema, Reducer } from '../util'; | ||
import type { JsonSchema, UISchemaElement } from '../models'; | ||
@@ -393,3 +393,7 @@ | ||
// Filter errors that match any keyword that we don't want to show in the UI | ||
if (filteredErrorKeywords.indexOf(error.keyword) !== -1) { | ||
// but keep the errors for oneOf enums | ||
if ( | ||
filteredErrorKeywords.indexOf(error.keyword) !== -1 && | ||
!isOneOfEnumSchema(error.parentSchema) | ||
) { | ||
return false; | ||
@@ -405,3 +409,3 @@ } | ||
// The same holds true for errors on the array level (e.g. min item amount). | ||
// In contrast, this comparison must not be done for errors whose parent schema defines an object | ||
// In contrast, this comparison must not be done for errors whose parent schema defines an object or a oneOf enum, | ||
// because the parent schema can never match the property schema (e.g. for 'required' checks). | ||
@@ -412,2 +416,3 @@ const parentSchema: JsonSchema | undefined = error.parentSchema; | ||
!isObjectSchema(parentSchema) && | ||
!isOneOfEnumSchema(parentSchema) && | ||
combinatorPaths.findIndex((p) => instancePath.startsWith(p)) !== -1 | ||
@@ -414,0 +419,0 @@ ) { |
@@ -40,3 +40,8 @@ /* | ||
} from '../models'; | ||
import { deriveTypes, hasType, resolveSchema } from '../util'; | ||
import { | ||
deriveTypes, | ||
hasType, | ||
isOneOfEnumSchema, | ||
resolveSchema, | ||
} from '../util'; | ||
@@ -357,7 +362,3 @@ /** | ||
uiTypeIs('Control'), | ||
schemaMatches( | ||
(schema) => | ||
schema.hasOwnProperty('oneOf') && | ||
(schema.oneOf as JsonSchema[]).every((s) => s.const !== undefined) | ||
) | ||
schemaMatches((schema) => isOneOfEnumSchema(schema)) | ||
); | ||
@@ -522,3 +523,3 @@ | ||
} | ||
if (val.oneOf && !isOneOfEnumControl(uischema, val, context)) { | ||
if (val.oneOf && !isOneOfEnumSchema(val)) { | ||
return true; | ||
@@ -525,0 +526,0 @@ } |
@@ -27,2 +27,3 @@ /* | ||
import find from 'lodash/find'; | ||
import { JsonSchema } from '../models'; | ||
@@ -42,1 +43,9 @@ export const getFirstPrimitiveProp = (schema: any) => { | ||
}; | ||
/** | ||
* Tests whether the schema has an enum based on oneOf. | ||
*/ | ||
export const isOneOfEnumSchema = (schema: JsonSchema) => | ||
schema?.hasOwnProperty('oneOf') && | ||
schema?.oneOf && | ||
(schema.oneOf as JsonSchema[]).every((s) => s.const !== undefined); |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1005149
13137