Skip to content

Commit d44f34a

Browse files
author
Ruben van Leeuwen
committed
2046: Adds jsdoc to isNullable function
1 parent 82d0a5a commit d44f34a

File tree

1 file changed

+7
-0
lines changed
  • frontend/packages/pydantic-forms/src/core

1 file changed

+7
-0
lines changed

frontend/packages/pydantic-forms/src/core/helper.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,13 @@ export const getFlatFieldMap = (
204204
return fieldMap;
205205
};
206206

207+
/**
208+
* Checks if the schema's type or one of the combinator props anyOf or oneOf contains a type of 'null'.
209+
* This tells us if the field is allowed to be null or not.
210+
*
211+
* @param schema A field from the 'properties' key of the JSON Schema
212+
* @returns true if the schema is nullable, false otherwise
213+
*/
207214
export const isNullable = (schema: PydanticFormPropertySchemaParsed) => {
208215
// Check if the schema has a type of 'null' or if it has an anyOf with a type of 'null'
209216
const isNullType = schema.type === PydanticFormFieldType.NULL;

0 commit comments

Comments
 (0)