Fix validation indicators on validation step table

This commit is contained in:
2025-03-09 17:44:03 -04:00
parent c295c330ff
commit de1408bd58
2 changed files with 10 additions and 10 deletions

View File

@@ -1,6 +1,6 @@
import React from 'react'
import { Field } from '../../../types'
import { Loader2, AlertCircle, CopyDown, ArrowDown } from 'lucide-react'
import { Loader2, AlertCircle, ArrowDown } from 'lucide-react'
import {
Tooltip,
TooltipContent,

View File

@@ -675,7 +675,7 @@ useEffect(() => {
const errors: ErrorType[] = [];
// Required field validation - improved to better handle various value types
if (field.validations?.some(v => v.type === 'required')) {
if (field.validations?.some(v => v.rule === 'required')) {
// Handle different value types more carefully
const isEmpty =
value === undefined ||
@@ -698,32 +698,32 @@ useEffect(() => {
if (field.validations) {
for (const validation of field.validations) {
// Skip required validation as we've already handled it
if (validation.type === 'required') continue;
if (validation.rule === 'required') continue;
if (validation.type === 'regex' && typeof value === 'string') {
if (validation.rule === 'regex' && typeof value === 'string') {
// Implement regex validation
const regex = new RegExp(validation.pattern!);
const regex = new RegExp(validation.value!);
if (!regex.test(value)) {
errors.push({
message: validation.message || 'Invalid format',
message: validation.errorMessage || 'Invalid format',
level: validation.level || 'error',
source: 'validation'
});
}
} else if (validation.type === 'min' && typeof value === 'number') {
} else if (validation.rule === 'min' && typeof value === 'number') {
// Implement min validation
if (value < validation.value) {
errors.push({
message: validation.message || `Value must be at least ${validation.value}`,
message: validation.errorMessage || `Value must be at least ${validation.value}`,
level: validation.level || 'error',
source: 'validation'
});
}
} else if (validation.type === 'max' && typeof value === 'number') {
} else if (validation.rule === 'max' && typeof value === 'number') {
// Implement max validation
if (value > validation.value) {
errors.push({
message: validation.message || `Value must be at most ${validation.value}`,
message: validation.errorMessage || `Value must be at most ${validation.value}`,
level: validation.level || 'error',
source: 'validation'
});