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 React from 'react'
import { Field } from '../../../types' import { Field } from '../../../types'
import { Loader2, AlertCircle, CopyDown, ArrowDown } from 'lucide-react' import { Loader2, AlertCircle, ArrowDown } from 'lucide-react'
import { import {
Tooltip, Tooltip,
TooltipContent, TooltipContent,

View File

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