Download the PHP package code-corner/validation without Composer

On this page you can find all versions of the php package code-corner/validation. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package validation

Validation Library

Introduction

This is a comprehensive validation library for PHP, providing various methods to validate different types of data against specified rules.

Installation

Ensure you have Composer installed. You can install the library using Composer by running:

Usage

  1. Require Composer's Autoload File

    Make sure to include Composer's autoload file at the beginning of your script:

  2. Use the Validation Class

    Use the Validation class from the CodeCorner\Validation namespace in your script:

  3. Perform Validation

    Define your validation rules and validate your data using the validate method of the Validation class:

    In this example:

    • name is required and must be at least 3 characters long.
    • email must be a valid email address.
    • age must be numeric and at least 18.
    • url must be a valid URL.
    • phone must be a valid phone number.
    • amount must be a decimal number.
    • role must be one of: admin, moderator, or user.
    • username must be unique (e.g., not already taken in a database).
    • password is nullable (optional) and if provided, must be a string of at least 6 characters.
  4. Available Validation Methods

    Here are the available validation methods and their usage:

    • required: The field must be present and not empty.
    • string: The field must be a string.
    • numeric: The field must be numeric.
    • in_array:val1,val2,...: The field must be one of the specified values.
    • array_required: The field must be an array and not empty.
    • file: The field must be a file upload. // 'size.5000000&type.png,jpeg&name.jpeg,png'
    • min:value: The field must be at least value characters long (for strings) or numeric value.
    • max:value: The field must be at most value characters long (for strings) or numeric value.
    • nullable: Allows the field to be null or empty.
    • unique:table,column: Checks if the field value is unique in a specified database table and column.
    • email: The field must be a valid email address.
    • URL: The field must be a valid URL.
    • regex:pattern: The field must match the specified regular expression pattern.
    • not_in:val1,val2,...: The field must not be one of the specified values.
    • in:val1,val2,...: Alias for in_array.
    • phone: The field must be a valid phone number.
    • decimal: The field must be a valid decimal number.
  5. Retrieve Validation Errors

    After performing validation, you can retrieve any validation errors using the getErrors method:

    This will output an array of validation errors encountered during the validation process.

  6. Using Database level validation

    • add your DB object in the config.php file.

    then you will use database level validation

Example

Here's a complete example of how you might use this library:

In this example:


All versions of validation with dependencies

PHP Build Version
Package Version
Requires giggsey/locale Version ^1.7|^2.0
php Version >=7.4.2
symfony/polyfill-mbstring Version ^1.17
giggsey/libphonenumber-for-php Version ^8.13
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package code-corner/validation contains the following files

Loading the files please wait ....