mirror of
https://github.com/Dictionarry-Hub/profilarr.git
synced 2026-01-22 10:51:02 +01:00
fix: validate condition names in format modal
- name must be included for format to be saved
This commit is contained in:
@@ -46,11 +46,15 @@ export const useFormatModal = (initialFormat, onSuccess) => {
|
||||
errors.conditions = 'At least one condition is required';
|
||||
} else {
|
||||
const invalidConditions = conditions.filter(condition => {
|
||||
// Check for missing condition name
|
||||
if (!condition.name?.trim()) {
|
||||
return true;
|
||||
}
|
||||
return !condition.field || !condition.operator;
|
||||
});
|
||||
if (invalidConditions.length > 0) {
|
||||
errors.conditions =
|
||||
'All conditions must have a field and operator';
|
||||
'All conditions must have a name, field, and operator';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -119,6 +123,17 @@ export const useFormatModal = (initialFormat, onSuccess) => {
|
||||
return;
|
||||
}
|
||||
|
||||
// Validate condition names
|
||||
const unnamedConditions = conditions.filter(
|
||||
condition => !condition.name?.trim()
|
||||
);
|
||||
if (unnamedConditions.length > 0) {
|
||||
errors.conditions = 'All conditions must have a name';
|
||||
Alert.error('All conditions must have a name');
|
||||
setFormErrors(errors);
|
||||
return;
|
||||
}
|
||||
|
||||
const invalidConditions = conditions.filter(condition => {
|
||||
// Each condition must have a type
|
||||
if (!condition.type) return true;
|
||||
|
||||
Reference in New Issue
Block a user