Support custom validation rules for ejected block fields (#12799)

This commit is contained in:
melohagan 2024-01-19 11:32:13 +00:00 committed by GitHub
parent 87be623057
commit af51a167a3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 21 additions and 22 deletions

View File

@ -88,7 +88,7 @@
<BlockComponent
type="form"
bind:id={formId}
props={{ dataSource, disableValidation: true }}
props={{ dataSource, disableSchemaValidation: true }}
>
{#if title || enrichedSearchColumns?.length || showTitleButton}
<BlockComponent

View File

@ -147,7 +147,7 @@
bind:id={formId}
props={{
dataSource,
disableValidation: true,
disableSchemaValidation: true,
editAutoColumns: true,
size,
}}

View File

@ -14,7 +14,7 @@
// Not exposed as a builder setting. Used internally to disable validation
// for fields rendered in things like search blocks.
export let disableValidation = false
export let disableSchemaValidation = false
// Not exposed as a builder setting. Used internally to allow searching on
// auto columns.
@ -103,7 +103,7 @@
{schema}
{table}
{initialValues}
{disableValidation}
{disableSchemaValidation}
{editAutoColumns}
{currentStep}
>

View File

@ -11,7 +11,7 @@
export let size
export let schema
export let table
export let disableValidation = false
export let disableSchemaValidation = false
export let editAutoColumns = false
// We export this store so that when we remount the inner form we can still
@ -156,12 +156,11 @@
if (!field) {
return
}
// Create validation function based on field schema
const schemaConstraints = schema?.[field]?.constraints
const validator = disableValidation
const schemaConstraints = disableSchemaValidation
? null
: createValidatorFromConstraints(
: schema?.[field]?.constraints
const validator = createValidatorFromConstraints(
schemaConstraints,
validationRules,
field,
@ -332,10 +331,10 @@
const { value, error } = fieldState
// Create new validator
const schemaConstraints = schema?.[field]?.constraints
const validator = disableValidation
const schemaConstraints = disableSchemaValidation
? null
: createValidatorFromConstraints(
: schema?.[field]?.constraints
const validator = createValidatorFromConstraints(
schemaConstraints,
validationRules,
field,