Download the PHP package gp/validator without Composer

On this page you can find all versions of the php package gp/validator. 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 validator

GP Validator Library

This library provides a robust validation engine to validate data inputs based on various rules. The library is modular and easily extensible, allowing you to create and use custom validation rules. which has various built in validation rules for common use cases (e.g., email, mobile number, numeric validation) also support for custom validation rules.

Table of Contents


Requirements


Installation

You can install gp_validator using Composer. Run the following command in your terminal:


Getting Started

After installation, you can start using the package by including the autoloader:


Features


Classes

Field

Methods

Method Description
getName() Returns the field's name.
getData() Returns the field's data.
getRules() Returns the validation rules associated with the field.
getErrors() Returns the errors for the field.
validate() Validates the field using the applied rules.
addRule(string $rule) Adds a validation rule to the field.
addError(string $error) Adds an error message to the field.

Fields

Methods

Method Description
addField(Field $field) Adds a single field to the collection.
addFields(Field ...$fields) Adds multiple fields to the collection.

ValidationEngine

Methods

Method Description
validate(Fields $fields) Validates all fields in the group.
validateField(Field $field) Validates a single field.

ValidationRule

Method

Method Description
validate(string $data, string &$msg): ?bool Validates the provided data and Returns resulthe method also populates
the $msg parameter with an error message if validation fails.

Usage

1. Creating a Validation Field

To validate a single field, create an instance of the Field class:

2. Validating a Single Field

Use the validate() method on a Field instance:

3. Grouping Fields for Validation

You can group multiple fields using the Fields class:

4. Validating All Fields in a Group

using the fields

Using the ValidationEngine

5. Built-in Validation Rules

The following validation rules are included in the library:

Rule Name Description
emailValidation Validates that the field contains a valid email.
mobileNumberValidation Validates that the field contains a valid mobile number in India.
landlineValidation Validates Indian landline numbers.
alphaSpaceValidation Validates that the field contains only alphabets and spaces.
isbnValidation Validates that the field contains a valid ISBN-10.
numericValidation Validates that the field contains a numeric value and optionally checks a range.
positiveNumberValidation Validates that the field contains a positive number.
regexValidation Validates data using a custom regular expression.
lengthValidation Validates the length of the data. Supports min and max length.
requiredValidation Validates that the field is not empty.

6. Creating Custom Validation Rules

To create a custom validation rule, implement the ValidationRule interface:

Then, apply the custom rule to a field:


Example

Here's a full example of validating multiple fields:


Contributing

Contributions are welcome! If you would like to contribute to gp_validator, please follow these steps:


License

This package is licensed under the MIT License. See the LICENSE file for more information.


Contact

For questions or issues, please reach out to the development team or open a ticket.


Author



All versions of validator with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
mockery/mockery Version ^1.6
gp/loader Version ^2.0.10
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 gp/validator contains the following files

Loading the files please wait ...