Fix validation indicators on validation step table
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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'
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user