mirror of
https://github.com/bknd-io/bknd/
synced 2026-08-03 16:46:00 +00:00
fix schema updates with falsy values
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -76,7 +76,7 @@ function AuthStrategiesListInternal() {
|
||||
|
||||
return (
|
||||
<Form
|
||||
schema={schema.toJSON()}
|
||||
schema={schema as any}
|
||||
initialValues={config}
|
||||
onSubmit={handleSubmit}
|
||||
options={formOptions}
|
||||
|
||||
Reference in New Issue
Block a user