@squiz/dx-json-schema-lib
Advanced tools
Comparing version 1.81.0 to 1.81.1
# Change Log | ||
## 1.81.1 | ||
### Patch Changes | ||
- ae5dd09: Support quickOption for boolean types | ||
## 1.81.0 | ||
@@ -4,0 +10,0 @@ |
@@ -94,3 +94,3 @@ "use strict"; | ||
jsonValidationService.validateManifest(invalidUiMetadata_json_1.default, 'v1'); | ||
}, SchemaValidationError_1.SchemaValidationError, 'failed validation: ui:metadata property quickOption is only valid for enum based properties.', { | ||
}, SchemaValidationError_1.SchemaValidationError, 'failed validation: ui:metadata property quickOption is only valid for boolean or enum based properties.', { | ||
'#/functions/0/input/properties/prop': [ | ||
@@ -104,3 +104,3 @@ { | ||
}, | ||
message: 'ui:metadata property quickOption is only valid for enum based properties.', | ||
message: 'ui:metadata property quickOption is only valid for boolean or enum based properties.', | ||
}, | ||
@@ -107,0 +107,0 @@ ], |
@@ -8,3 +8,3 @@ "use strict"; | ||
const uiMetadata = fieldValue['ui:metadata']; | ||
if (uiMetadata === null || uiMetadata === void 0 ? void 0 : uiMetadata.quickOption) { | ||
if ((uiMetadata === null || uiMetadata === void 0 ? void 0 : uiMetadata.quickOption) && fieldValue.type !== 'boolean') { | ||
if (!fieldValue.enum) { | ||
@@ -15,3 +15,3 @@ const error = { | ||
type: 'error', | ||
message: `ui:metadata property quickOption is only valid for enum based properties.`, | ||
message: `ui:metadata property quickOption is only valid for boolean or enum based properties.`, | ||
data: { expected: 'enum', pointer: pointer, received: typeof value, value: value }, | ||
@@ -18,0 +18,0 @@ }; |
@@ -27,2 +27,9 @@ "use strict"; | ||
}); | ||
it('quickOption is valid for boolean types', () => { | ||
const result = customKeywordValidators_1.customKeywordValidators['ui:metadata']( | ||
// eslint-disable-next-line | ||
// @ts-ignore - the null properties aren't used in this keyword validation | ||
null, null, { type: 'boolean', 'ui:metadata': { quickOption: true } }, '#/functions/0/input/properties/users-contact'); | ||
expect(result).toBe(undefined); | ||
}); | ||
it('quickOption:false is valid without enum', () => { | ||
@@ -29,0 +36,0 @@ const result = customKeywordValidators_1.customKeywordValidators['ui:metadata']( |
{ | ||
"name": "@squiz/dx-json-schema-lib", | ||
"version": "1.81.0", | ||
"version": "1.81.1", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -124,3 +124,3 @@ import { JsonValidationService } from './JsonValidationService'; | ||
SchemaValidationError, | ||
'failed validation: ui:metadata property quickOption is only valid for enum based properties.', | ||
'failed validation: ui:metadata property quickOption is only valid for boolean or enum based properties.', | ||
{ | ||
@@ -135,3 +135,3 @@ '#/functions/0/input/properties/prop': [ | ||
}, | ||
message: 'ui:metadata property quickOption is only valid for enum based properties.', | ||
message: 'ui:metadata property quickOption is only valid for boolean or enum based properties.', | ||
}, | ||
@@ -138,0 +138,0 @@ ], |
@@ -44,2 +44,15 @@ import { customKeywordValidators } from './customKeywordValidators'; | ||
it('quickOption is valid for boolean types', () => { | ||
const result = customKeywordValidators['ui:metadata']( | ||
// eslint-disable-next-line | ||
// @ts-ignore - the null properties aren't used in this keyword validation | ||
null, | ||
null, | ||
{ type: 'boolean', 'ui:metadata': { quickOption: true } }, | ||
'#/functions/0/input/properties/users-contact', | ||
); | ||
expect(result).toBe(undefined); | ||
}); | ||
it('quickOption:false is valid without enum', () => { | ||
@@ -46,0 +59,0 @@ const result = customKeywordValidators['ui:metadata']( |
@@ -12,3 +12,3 @@ import { Draft, JSONError, JSONSchema } from '@squiz/json-schema-library'; | ||
if (uiMetadata?.quickOption) { | ||
if (uiMetadata?.quickOption && fieldValue.type !== 'boolean') { | ||
if (!fieldValue.enum) { | ||
@@ -19,3 +19,3 @@ const error: JSONError = { | ||
type: 'error', | ||
message: `ui:metadata property quickOption is only valid for enum based properties.`, | ||
message: `ui:metadata property quickOption is only valid for boolean or enum based properties.`, | ||
data: { expected: 'enum', pointer: pointer, received: typeof value, value: value }, | ||
@@ -22,0 +22,0 @@ }; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
999527
23933