Skip to content

Commit d13657b

Browse files
authored
Merge pull request #185 from lehors/issue-184
Allow changing the casing of the name of an existing model
2 parents 2dc0707 + 91df54b commit d13657b

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

web/modules/mof/src/Plugin/Validation/Constraint/ModelNameConstraintValidator.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,17 @@ public function validate($field, Constraint $constraint) {
5555
->execute();
5656

5757
if (!empty($query)) {
58+
// Because the query is case insensitive if we are just changing the casing of the name
59+
// of an existing model it returns the very same model, in which case we don't raise an error.
60+
if (reset($query) == $entity->id() && count($query) == 1)
61+
return;
5862
$this
5963
->context
6064
->buildViolation($constraint->errorMessage)
6165
->setParameter('%value', $value)
6266
->atPath('label')
6367
->addViolation();
64-
}
68+
}
6569
}
6670
}
6771

0 commit comments

Comments
 (0)