Download the PHP package denizgolbas/laravel-equality-validation without Composer

On this page you can find all versions of the php package denizgolbas/laravel-equality-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 laravel-equality-validation

Laravel Equality Validation

Tests Packagist Packagist Downloads PHP Version Laravel Version

A powerful Laravel validation rule for checking equality between reference and target model columns. Perfect for validating relationships, matching codes, currencies, and ensuring data consistency across related models.

Installation

You can install the package via Composer:

The package will automatically register its service provider.

Configuration

You can publish the config file with:

Usage

This validation rule allows you to validate that a column value from a reference model matches a column value from a target model.

Example 1: Basic Request Validation

Example 2: Using FormRequest Class

Example 3: Validating Warehouse and Product Location

Example 4: Validating Multiple Items in Array

Example 5: Validating User and Company Relationship

Example 6: Validating Nested Data Structure

Example 7: Using Helper Method (Alternative Syntax)

Parameters

The EqualityValidationRule constructor accepts the following parameters:

  1. $referenceModel (string): The fully qualified class name of the reference model
  2. $referenceColumn (string): The column name in the reference model to compare
  3. $targetModel (string): The fully qualified class name of the target model
  4. $targetColumn (string): The column name in the target model to compare
  5. $targetAttribute (string): The attribute name in the request that contains the target model ID
  6. $sameLine (bool, optional): Whether to use the same line/level for finding the target attribute. Defaults to true

Same Line Parameter

When $sameLine is true (default), the rule will look for the target attribute at the same nesting level as the reference attribute. For example:

When $sameLine is false, it will use the base attribute name:

Example 8: Real-World E-Commerce Scenario

Example 9: Validating with Different Column Names

Translation

The package includes English and Turkish translations. You can publish the language files to customize the error messages:

This will publish the language files to lang/vendor/equality-validation/{locale}/validation.php.

After publishing, you can customize the error messages in the published files.

The default error message is:

English:

The :reference_column of :reference_model does not match the :target_column of :target_model.

Turkish:

:reference_model'in :reference_column değeri, :target_model'in :target_column değeri ile eşleşmiyor.

If you want to use the translations in your application's main language files instead, you can copy the validation key to your lang/{locale}/validation.php file under the custom key.

Testing

License

The MIT License (MIT). Please see License File for more information.

Author

Deniz Golbas - [email protected]


All versions of laravel-equality-validation with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
illuminate/contracts Version ^10.0|^11.0
illuminate/support Version ^10.0|^11.0
illuminate/validation Version ^10.0|^11.0
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 denizgolbas/laravel-equality-validation contains the following files

Loading the files please wait ...