Browse Source
Merge pull request #5290 from Upgreydd/Do_not_validate_if_multi-select_options_length_is_0
Do not validate if multi-select options length is 0
pull/5528/head
Martin McKeaveney
4 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with
7 additions and
4 deletions
-
packages/builder/src/components/backend/DataTable/RowFieldControl.svelte
-
packages/server/src/api/controllers/row/utils.js
|
|
|
@ -34,10 +34,10 @@ |
|
|
|
$: label = meta.name ? capitalise(meta.name) : "" |
|
|
|
|
|
|
|
const timeStamp = resolveTimeStamp(value) |
|
|
|
const isTimeStamp = timeStamp ? true : false |
|
|
|
const isTimeStamp = !!timeStamp |
|
|
|
</script> |
|
|
|
|
|
|
|
{#if type === "options"} |
|
|
|
{#if type === "options" && meta.constraints.inclusion.length !== 0} |
|
|
|
<Select |
|
|
|
{label} |
|
|
|
data-cy="{meta.name}-select" |
|
|
|
@ -51,7 +51,7 @@ |
|
|
|
<Dropzone {label} bind:value /> |
|
|
|
{:else if type === "boolean"} |
|
|
|
<Toggle text={label} bind:value data-cy="{meta.name}-input" /> |
|
|
|
{:else if type === "array"} |
|
|
|
{:else if type === "array" && meta.constraints.inclusion.length !== 0} |
|
|
|
<Multiselect bind:value {label} options={meta.constraints.inclusion} /> |
|
|
|
{:else if type === "link"} |
|
|
|
<LinkedRowSelector bind:linkedRows={value} schema={meta} /> |
|
|
|
|
|
|
|
@ -65,7 +65,10 @@ exports.validate = async ({ tableId, row, table }) => { |
|
|
|
if (type === FieldTypes.ARRAY && row[fieldName]) { |
|
|
|
if (row[fieldName].length) { |
|
|
|
row[fieldName].map(val => { |
|
|
|
if (!constraints.inclusion.includes(val)) { |
|
|
|
if ( |
|
|
|
!constraints.inclusion.includes(val) && |
|
|
|
constraints.inclusion.length !== 0 |
|
|
|
) { |
|
|
|
errors[fieldName] = "Field not in list" |
|
|
|
} |
|
|
|
}) |
|
|
|
|