Skip to content

[Validator] Add Video constraint for validating video files #59042

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 16 commits into
base: 7.4
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Replace ctype_digit check with just a lower than comparison
  • Loading branch information
symfonyaml committed Jan 12, 2025
commit 1b26cf23fb262e1155c9efbc6871e35e0bf9aa3f
12 changes: 6 additions & 6 deletions src/Symfony/Component/Validator/Constraints/VideoValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public function validate(mixed $value, Constraint $constraint): void
$height = $dimensions->getHeight();

if ($constraint->minWidth) {
if (!ctype_digit((string) $constraint->minWidth)) {
if ($constraint->minWidth < 0) {
throw new ConstraintDefinitionException(\sprintf('"%s" is not a valid minimum width.', $constraint->minWidth));
}

Expand All @@ -85,7 +85,7 @@ public function validate(mixed $value, Constraint $constraint): void
}

if ($constraint->maxWidth) {
if (!ctype_digit((string) $constraint->maxWidth)) {
if ($constraint->maxWidth < 0) {
throw new ConstraintDefinitionException(\sprintf('"%s" is not a valid maximum width.', $constraint->maxWidth));
}

Expand All @@ -101,7 +101,7 @@ public function validate(mixed $value, Constraint $constraint): void
}

if ($constraint->minHeight) {
if (!ctype_digit((string) $constraint->minHeight)) {
if ($constraint->minHeight < 0) {
throw new ConstraintDefinitionException(\sprintf('"%s" is not a valid minimum height.', $constraint->minHeight));
}

Expand All @@ -117,7 +117,7 @@ public function validate(mixed $value, Constraint $constraint): void
}

if ($constraint->maxHeight) {
if (!ctype_digit((string) $constraint->maxHeight)) {
if ($constraint->maxHeight < 0) {
throw new ConstraintDefinitionException(\sprintf('"%s" is not a valid maximum height.', $constraint->maxHeight));
}

Expand All @@ -133,7 +133,7 @@ public function validate(mixed $value, Constraint $constraint): void
$pixels = $width * $height;

if (null !== $constraint->minPixels) {
if (!ctype_digit((string) $constraint->minPixels)) {
if ($constraint->minPixels < 0) {
throw new ConstraintDefinitionException(\sprintf('"%s" is not a valid minimum amount of pixels.', $constraint->minPixels));
}

Expand All @@ -149,7 +149,7 @@ public function validate(mixed $value, Constraint $constraint): void
}

if (null !== $constraint->maxPixels) {
if (!ctype_digit((string) $constraint->maxPixels)) {
if ($constraint->maxPixels < 0) {
throw new ConstraintDefinitionException(\sprintf('"%s" is not a valid maximum amount of pixels.', $constraint->maxPixels));
}

Expand Down
Loading