Skip to content
Snippets Groups Projects

Added a contraint to check for empty file upload.

Open Amey Mudras requested to merge issue/drupal-3345450:3345450-restrict-the-upload into 11.x
2 unresolved threads

Closes #3345450

Changes:

  • Added a validation constraint which checks if the uploaded file size is of zero bytes

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
8 * Zero Byte File constraint.
9 *
10 * @Constraint(
11 * id = "RestrictZeroByteFile",
12 * label = @Translation("Restrict zero byte file", context = "Validation"),
13 * type = "file"
14 * )
15 */
16 class RestrictZeroByteFileConstraint extends Constraint {
17
18 /**
19 * The message for when a empty file is uploaded.
20 *
21 * @var string
22 */
23 public string $zeroByteFileMessage = 'The uploaded is empty! Please upload a valid file.';
  • 4
    5 use Symfony\Component\Validator\Constraint;
    6
    7 /**
    8 * Zero Byte File constraint.
    9 *
    10 * @Constraint(
    11 * id = "RestrictZeroByteFile",
    12 * label = @Translation("Restrict zero byte file", context = "Validation"),
    13 * type = "file"
    14 * )
    15 */
    16 class RestrictZeroByteFileConstraint extends Constraint {
    17
    18 /**
    19 * The message for when a empty file is uploaded.
  • Lap Pham added 14 commits

    added 14 commits

    • 7a4e49a4...a9865eb3 - 12 commits from branch project:11.x
    • e5a061dd - Added a contraint to check for empty file upload.
    • 739bdcc6 - Merge remote-tracking branch 'drupal-3345450/3345450-restrict-the-upload' into...

    Compare with previous version

  • Lap Pham added 1 commit

    added 1 commit

    • 52b63667 - Rename class to match with other constraint class. Add tests. Improve message.

    Compare with previous version

  • Lap Pham added 1 commit

    added 1 commit

    Compare with previous version

  • Please register or sign in to reply
    Loading