fix schema updates with falsy values

This commit is contained in:
dswbx
2025-07-09 08:48:05 +02:00
parent 682ecc6dac
commit 0a49061549
5 changed files with 16 additions and 7 deletions
+7 -1
View File
@@ -1,7 +1,13 @@
/// <reference types="@cloudflare/workers-types" />
import type { App } from "App";
import { datetimeStringLocal, datetimeStringUTC, getTimezone, getTimezoneOffset, $console } from "core/utils";
import {
datetimeStringLocal,
datetimeStringUTC,
getTimezone,
getTimezoneOffset,
$console,
} from "core/utils";
import { getRuntimeKey } from "core/utils";
import type { Context, Hono } from "hono";
import { Controller } from "modules/Controller";
@@ -4,10 +4,13 @@ import type { JSONSchema } from "json-schema-to-ts";
import type { JSONSchemaType } from "json-schema-to-ts/lib/types/definitions/jsonSchema";
export { isEqual, getPath } from "core/utils/objects";
//export { isEqual } from "lodash-es";
export function isNotDefined(value: any) {
return value === null || value === undefined || value === "";
}
export function coerce(value: any, schema: JsonSchema, opts?: { required?: boolean }) {
if (!value && typeof opts?.required === "boolean" && !opts.required) {
if (isNotDefined(value) && typeof opts?.required === "boolean" && !opts.required) {
return undefined;
}
+1 -1
View File
@@ -76,7 +76,7 @@ function AuthStrategiesListInternal() {
return (
<Form
schema={schema.toJSON()}
schema={schema as any}
initialValues={config}
onSubmit={handleSubmit}
options={formOptions}