From 3a877d156e46a0de20f1cc243b3c14921c6f5019 Mon Sep 17 00:00:00 2001 From: Aliaksandra Ramanenka Date: Tue, 6 Aug 2024 16:56:00 +0300 Subject: [PATCH] FIO-8632: Fixes an issue where required validation is not triggered for multiple value components like Select if it has no values added --- src/process/validation/index.ts | 8 -------- src/process/validation/rules/validateRegexPattern.ts | 4 ++-- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/src/process/validation/index.ts b/src/process/validation/index.ts index 5322a3f4..bf162350 100644 --- a/src/process/validation/index.ts +++ b/src/process/validation/index.ts @@ -48,14 +48,6 @@ export function validationRules( } const validationRules: ValidationRuleInfo[] = []; return rules.reduce((acc, rule: ValidationRuleInfo) => { - if (context.component.multiple && - Array.isArray(context.value) && - context.value?.length === 0 && - !rule.fullValue - ) { - return acc; - } - if (rule.shouldProcess && rule.shouldProcess(context)) { acc.push(rule); } diff --git a/src/process/validation/rules/validateRegexPattern.ts b/src/process/validation/rules/validateRegexPattern.ts index cd76596a..4835ae85 100644 --- a/src/process/validation/rules/validateRegexPattern.ts +++ b/src/process/validation/rules/validateRegexPattern.ts @@ -1,4 +1,4 @@ -import { FieldError } from 'error'; +import { FieldError } from '../../../error'; import { TextAreaComponent, TextFieldComponent, RuleFn, RuleFnSync, ValidationContext } from 'types'; import { ProcessorInfo } from 'types/process/ProcessorInfo'; @@ -15,7 +15,7 @@ export const shouldValidate = (context: ValidationContext) => { } const pattern = component.validate?.pattern; - if (!pattern) { + if (!pattern || !value || typeof value !== 'string') { return false; } return true;