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