PHPackages                             secit-pl/validation-bundle - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [File &amp; Storage](/categories/file-storage)
4. /
5. secit-pl/validation-bundle

ActiveSymfony-bundle[File &amp; Storage](/categories/file-storage)

secit-pl/validation-bundle
==========================

Additional Symfony validators.

4.0.0(1mo ago)614.6k↓41.7%2MITPHPPHP &gt;=8.4.0

Since Jun 7Pushed 1mo agoCompare

[ Source](https://github.com/secit-pl/validation-bundle)[ Packagist](https://packagist.org/packages/secit-pl/validation-bundle)[ Docs](https://secit.pl)[ RSS](/packages/secit-pl-validation-bundle/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependencies (16)Versions (17)Used By (0)

Symfony Validation Bundle
=========================

[](#symfony-validation-bundle)

Additional validators for Symfony.

Compatibility matrix
--------------------

[](#compatibility-matrix)

Bundle versionMaintainedSymfony versionsMin. PHP version4.xYes8.x, 7.x8.4.03.xNo7.x8.2.02.xNo6.x8.0.01.8No5.x, 4.x7.1.0Installation
------------

[](#installation)

From the command line run

```
$ composer require secit-pl/validation-bundle

```

Validators
----------

[](#validators)

### FileExtension

[](#fileextension)

This validator checks if file has valid file extension.

> From Symfony 6.2 you can also use the "extensions" option in File validator.
>
>
>
>

Example usage

```
use SecIT\ValidationBundle\Validator\Constraints as SecITAssert;

// ...

#[SecITAssert\FileExtension(["jpg", "jpeg", "png"])]
private $file;
```

```
use SecIT\ValidationBundle\Validator\Constraints as SecITAssert;

// ...

#[SecITAssert\FileExtension(disallowedExtensions: ["jpg", "jpeg", "png"])]
private $file;
```

Parameters

ParameterTypeDefaultDescriptionvalidExtensionsarrayempty arrayAllowed/valid file extensions listdisallowedExtensionsarrayempty arrayDisallowed/invalid file extensions listmatchCaseboolfalseEnable/disable verifying the file extension case**Caution!** It's highly recommended to use this validator together with native Symfony File/Image validator.

```
use SecIT\ValidationBundle\Validator\Constraints as SecITAssert;
use Symfony\Component\Validator\Constraints as Assert;

// ...

#[Assert\Image(maxSize: '2M', mimeTypes: ["image/jpg", "image/jpeg", "image/png"])]
#[SecITAssert\FileExtension(validExtensions: ["jpg", "jpeg", "png"])]
private $file;
```

### CollectionOfUniqueElements

[](#collectionofuniqueelements)

Checks if collection contains only unique elements.

> From Symfony 6.0 you can also use the Unique validator.
>
>

Parameters

ParameterTypeDefaultDescriptionmatchCaseboolfalseEnable/disable verifying the characters casecustomNormalizationFunctionnull or callablenullCustom normalization function```
use SecIT\ValidationBundle\Validator\Constraints as SecITAssert;

// ...

#[SecITAssert\CollectionOfUniqueElements()]
private $collection;
```

This validator can also be used to validate unique files upload.

```
