Download the PHP package brunoconte3/dev-utils without Composer
On this page you can find all versions of the php package brunoconte3/dev-utils. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download brunoconte3/dev-utils
More information about brunoconte3/dev-utils
Files in brunoconte3/dev-utils
Package dev-utils
Short Description Dev-utils is complete, validates, formats, compares data, plus utilities
License MIT
Informations about the package dev-utils
dev-utils
A complete library, with PSR standard and guarantee of all methods unit tested by phpunit and passed by phpstan.
- Class of Arrays
- Comparison Class
- Formatting Class
- Utility Class
- Validate Data in General
- Validate Upload Files
Installation
composer.json
With composer, require
Data Validation Example
Data
Rules
Validating the data according to the rules
Validating File(s) Upload
With validators fileName, maxFile, maxUploadSize, mimeType, minFile, minUploadSize, minHeight, minWidth, maxHeight, maxWidth and requiredFile, you can set the minimum and maximum size (bytes) of the file; minimum and maximum amount of files; allowed extensions; minimum and maximum height and length of images, validate the name of the file and define if the field of type "File" is mandatory.
Example:
Validation types (validators)
- alpha:
Checks that the field contains only alphabetic characters
- alphaNoSpecial:
Checks if the field contains regular text characters, it cannot have accents
- alphaNum:
Checks if the field contains alphanumeric characters
- alphaNumNoSpecial:
Checks if the field contains letters without accents, numbers, cannot special character
- array:
Checks if the variable is an array
- arrayValues:
Checks whether the variable has one of the options in the specified array
- bool:
Values of logical type.
Ex: true or false, 1 or 0, yes or no
- companyIdentification:
Validates if the CNPJ is valid, passing CNPJ with or without mask
- dateAmerican:
Validates if the American date is valid
- dateBrazil:
Validates if the Brazilian date is valid
- dateNotFuture:
Validates if the date not greater than date current (accepts Brazilian or American format)
- ddd:
Validates ddd informed in YYY or YY format, by UF or in general
Ex: ddd:pr, ddd do Paraná/Brazil, or just ddd
- email:
Check if it's a valid email
- equals:
Checks if the field is the same as another field, example above in the documentation, look for equals
- fileName:
Checks that the filename is a valid name, and formats the name by removing special characters
- float:
Checks if the value is of type floating(real value)
- hour:
Validates if the time is valid
- identifier:
Validates if the CPF is valid, passing CPF with or without mask
- identifierOrCompany:
Validates if the CPF or CNPJ is valid, passing CPF or CNPJ with or without mask
- int:
Checks if the value is of type integer (If the format is String, it tries to parse it)
- integer:
Checks if the value is of type integer (here checks exact typing)
- ip:
Checks if the value is a valid IP address
- json:
Checks if the value is a valid json
- lower:
Checks if all characters are lowercase
- mac:
Checks if the value is a valid MAC address
- max:
Sets the maximum size of the value
- minHeight:
Sets the minimum height size (pixels) of the image
- minWidth:
Sets the minimum size in length (pixels) of the image
- maxHeight: Sets the maximum height (pixels) size of the image``
- maxWidth:
Sets the maximum size in length (pixels) of the image
- maxFile:
Sets the maximum number of files to upload
- maxUploadSize:
Sets the maximum file size (bytes)
- maxWords:
Defines the maximum number of words in a string
- min:
Sets the minimum size of the value
- minFile:
Sets the minimum amount of files to upload
- minWords:
Defines the minimum number of words in a string
- mimeType:
Defines the extension(s) allowed for upload
- minUploadSize:
Sets the minimum file size (bytes)
- numeric:
Checks if the value contains only numeric values (Left zero accepted)
- numMax:
Sets a maximum value, with the minimum being zero
- numMin:
Sets a minimum value, with the minimum being zero
- numMonth:
Checks if the value is a valid month (1 to 12)
- notSpace:
Checks if the string contains spaces
- noWeekend:
Checks if the date (Brazilian or American is not a Weekend)
- optional:
If inserted, it only validates if the value is different from empty, null or false
- phone:
Checks if the value matches a valid phone. (DDD + NUMBERS) 10 or 11 digits
- plate:
Checks if the value matches the shape of a license plate
- regex:
Defines a rule for the value through a regular expression
- required:
Set the field to mandatory
- requiredFile:
Sets the field of type 'File' as mandatory
- rgbColor:
Checks if the string has a valid RGB Color
- timestamp:
Checks if the value is a valid timestamp (accepts Brazilian or American format)
- upper:
Checks if all characters are uppercase
- url:
Checks if the value is a valid URL address
- zipcode:
Checks if the value matches the format of a zip code
Defining custom message
After defining some of our rules to the data you can also add a custom message using the ',' delimiter in some specific rule or using the default message.
Example:
Formatting Examples
Formatting Upload File(s)
Example: Uploading a single file
Example: Uploading multiple files
Comparisons Examples
Validations in the form of Methods
Manipulate Arrays
Utilities
Check the minimum coverage of CI/CD unit tests using PHPUnit
Will perform pull request, please execute unit tests, and phpstan level 9
./vendor/bin/phpunit --coverage-xml coverage
If you don't know how to run phpstan, I execute and adjust whatever is necessary
License
The validator is an open-source application licensed under the MIT License.