Skip to content

Commit

Permalink
FIO-8632: Fixes an issue where required validation is not triggered f…
Browse files Browse the repository at this point in the history
…or multiple value components like Select if it has no values added
  • Loading branch information
alexandraRamanenka committed Aug 6, 2024
1 parent dbd8da3 commit 3a877d1
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 10 deletions.
8 changes: 0 additions & 8 deletions src/process/validation/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
4 changes: 2 additions & 2 deletions src/process/validation/rules/validateRegexPattern.ts
Original file line number Diff line number Diff line change
@@ -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';

Expand All @@ -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;
Expand Down

0 comments on commit 3a877d1

Please sign in to comment.