Skip to content

Commit

Permalink
fix(service): properly validate UUID if the format is omitted
Browse files Browse the repository at this point in the history
  • Loading branch information
P0Xyio committed Nov 14, 2024
1 parent b28873a commit 6c8e135
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions server/src/services/service.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { Core } from '@strapi/strapi';
import { errors } from '@strapi/utils';
import { generateUUID, validateUUID } from '../../../admin/src/utils/helpers';
import { generateUUID, isValidUUIDValue } from '../../../admin/src/utils/helpers';

const { YupValidationError } = errors;

Expand Down Expand Up @@ -37,7 +37,7 @@ const service = ({ strapi }: { strapi: Core.Strapi }) => ({
// - If disableAutoFill is not enabled
// - If there is an initial value
if (!disableAutoFill || initialValue) {
if (!validateUUID(uuidFormat, event.params.data[attribute])) {
if (!isValidUUIDValue(uuidFormat, event.params.data[attribute])) {
errorMessages.inner.push({
name: 'ValidationError', // Always set to ValidationError
path: attribute, // Name of field we want to show input validation on
Expand Down

0 comments on commit 6c8e135

Please sign in to comment.