Fix/enum bug (#4659)

* fix: sever not throwing when enum contains two identical values

* fix: enum column name cannot be change

* fix: put field create/update inside transactions

* fix: check for options duplicate values front-end

* fix: missing commit transaction
This commit is contained in:
Jérémy M
2024-03-26 16:16:29 +01:00
committed by GitHub
parent ab028b8c22
commit 3acec7731c
5 changed files with 329 additions and 206 deletions

View File

@ -14,6 +14,8 @@ import { validateOptionsForType } from 'src/engine/metadata-modules/field-metada
@Injectable()
@ValidatorConstraint({ name: 'isFieldMetadataOptions', async: true })
export class IsFieldMetadataOptions {
private validationErrors: string[] = [];
constructor(private readonly fieldMetadataService: FieldMetadataService) {}
async validate(
@ -42,10 +44,20 @@ export class IsFieldMetadataOptions {
type = fieldMetadata.type;
}
return validateOptionsForType(type, value);
try {
return validateOptionsForType(type, value);
} catch (err) {
this.validationErrors.push(err.message);
return false;
}
}
defaultMessage(): string {
if (this.validationErrors.length > 0) {
return this.validationErrors.join(', ');
}
return 'FieldMetadataOptions is not valid';
}
}