From 6f5c58b6fdb88d31769ffb9dd74211e7c51f474f Mon Sep 17 00:00:00 2001 From: Dan O'Neill Date: Thu, 5 Mar 2026 18:33:21 -0800 Subject: [PATCH 1/5] add boolean to the union --- src/common/types.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/common/types.ts b/src/common/types.ts index 436b267..8587696 100644 --- a/src/common/types.ts +++ b/src/common/types.ts @@ -34,7 +34,7 @@ export interface V2Schema { // Base property interface for nested properties (doesn't require deprecated/title) export interface V2BaseProperty { - type: 'string' | 'number' | 'array' | 'object'; + type: 'boolean' | 'string' | 'number' | 'array' | 'object'; description?: string; default?: any; minimum?: number; @@ -60,7 +60,7 @@ export interface V2Property extends V2BaseProperty { } export interface V2UIField { - type: 'TEXT' | 'NUMERIC' | 'CHOICE_LIST' | 'DATE_TIME' | 'LOCATION' | 'COLLECTION' | 'ATTACHMENT'; + type: 'BOOLEAN' | 'TEXT' | 'NUMERIC' | 'CHOICE_LIST' | 'DATE_TIME' | 'LOCATION' | 'COLLECTION' | 'ATTACHMENT'; parent: string; inputType?: 'SHORT_TEXT' | 'LONG_TEXT' | 'DROPDOWN' | 'LIST'; placeholder?: string; From eead87d9f1750e2ef144a77913813a68e6593907 Mon Sep 17 00:00:00 2001 From: Dan O'Neill Date: Thu, 5 Mar 2026 18:33:40 -0800 Subject: [PATCH 2/5] add BOOLEAN to supportedFieldTypes --- src/v2/generateUISchema.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/v2/generateUISchema.ts b/src/v2/generateUISchema.ts index 4ce0708..78d121c 100644 --- a/src/v2/generateUISchema.ts +++ b/src/v2/generateUISchema.ts @@ -20,7 +20,7 @@ import { validateConditions } from './conditions'; */ const validateV2Schema = (schema: V2Schema): void => { const invalidFields: string[] = []; - const supportedFieldTypes = ['TEXT', 'NUMERIC', 'DATE_TIME', 'CHOICE_LIST', 'LOCATION', 'COLLECTION', 'ATTACHMENT']; + const supportedFieldTypes = ['BOOLEAN', 'TEXT', 'NUMERIC', 'DATE_TIME', 'CHOICE_LIST', 'LOCATION', 'COLLECTION', 'ATTACHMENT']; // Check each field for validity Object.entries(schema.json.properties).forEach(([fieldName, property]) => { From 32da391a5d6c2fa2acd500cc4fa13a27fc12893a Mon Sep 17 00:00:00 2001 From: Dan O'Neill Date: Thu, 5 Mar 2026 18:34:06 -0800 Subject: [PATCH 3/5] Added BOOLEAN case to createControl --- src/v2/utils.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/v2/utils.ts b/src/v2/utils.ts index b0e7aeb..c198a9f 100644 --- a/src/v2/utils.ts +++ b/src/v2/utils.ts @@ -44,6 +44,10 @@ export const createControl = ( // Add format based on field type switch (uiField.type) { + case "BOOLEAN": + control.options!.format = "boolean"; + break; + case "TEXT": if (uiField.inputType === "LONG_TEXT") { control.options!.multi = true; From 1467a66d3385b56587b0aecc9c22cc36dfd19cae Mon Sep 17 00:00:00 2001 From: Dan O'Neill Date: Thu, 5 Mar 2026 18:34:15 -0800 Subject: [PATCH 4/5] initial tests --- test/v2.test.ts | 74 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) diff --git a/test/v2.test.ts b/test/v2.test.ts index 02b9e79..068011d 100644 --- a/test/v2.test.ts +++ b/test/v2.test.ts @@ -488,6 +488,80 @@ describe('V2 generateUISchema', () => { }); +describe('BOOLEAN field type', () => { + const booleanSchema: V2Schema = { + json: { + $schema: 'https://json-schema.org/draft/2020-12/schema', + additionalProperties: false, + properties: { + requires_medicine: { + deprecated: false, + title: 'Animal Requires Medicine', + default: true, + description: 'Does the veterinarian require medicine for the animal?', + type: 'boolean', + }, + }, + required: [], + type: 'object', + }, + ui: { + fields: { + requires_medicine: { + conditionalDependents: [], + parent: 'section-1', + type: 'BOOLEAN', + }, + }, + headers: {}, + order: ['section-1'], + sections: { + 'section-1': { + columns: 1, + conditions: [], + isActive: true, + label: 'Animal Care', + leftColumn: [{ name: 'requires_medicine', type: 'field' }], + rightColumn: [], + }, + }, + }, + }; + + it('generates a Control with boolean format', () => { + const result = generateUISchema(booleanSchema); + const control = result.elements![0].elements![0]; + expect(control).toMatchObject({ + type: 'Control', + scope: '#/properties/requires_medicine', + label: 'Animal Requires Medicine', + options: { format: 'boolean' }, + }); + }); + + it('includes the description in options', () => { + const result = generateUISchema(booleanSchema); + const control = result.elements![0].elements![0]; + expect(control.options!.description).toBe( + 'Does the veterinarian require medicine for the animal?', + ); + }); + + it('deprecated boolean field is not rendered', () => { + const schema: V2Schema = { + ...booleanSchema, + json: { + ...booleanSchema.json, + properties: { + requires_medicine: { ...booleanSchema.json.properties.requires_medicine, deprecated: true }, + }, + }, + }; + const result = generateUISchema(schema); + expect(result.elements).toHaveLength(0); + }); +}); + // Helper function to extract all controls from nested structure function getAllControls(uiSchema: any): any[] { const controls: any[] = []; From a479c71a37cf6fa34a948fd104893f877dc7d3b4 Mon Sep 17 00:00:00 2001 From: Dan O'Neill Date: Thu, 5 Mar 2026 19:04:19 -0800 Subject: [PATCH 5/5] version bump --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index b40782d..4918f85 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@earthranger/react-native-jsonforms-formatter", - "version": "2.0.0-beta.24", + "version": "2.0.0-beta.25", "description": "Converts JTD into JSON Schema ", "main": "./dist/bundle.js", "types": "./dist/index.d.ts",