logadapp/validator

Request Validation library

v0.0.1 2023-05-08 19:41 UTC

This package is auto-updated.

Last update: 2024-04-20 10:32:21 UTC


README


LogadApp\Validator

Report Bug · Request Feature

About The Project

Features

  • Simple to use
  • Supports underscores and camelcase (file_size or fileSize)
  • Easy to create your own rules
  • File validation
  • Min\Max length validation
  • Email validation
  • File size validation
  • Conditional requirements
  • Similar to Laravel's validation feature
  • Inspired by Rakit\Validation

Installation

How to install.

  1. Using composer
    composer require logadapp/validator
  2. Include the generated autoload in your file, See index.php for example

Usage

<?php

use LogadApp\Validator\Validation;

require('vendor/autoload.php');

$validator = new Validation;
$rules = [
    'test' => 'required|numeric|max:10|min:5',
    'text' => 'required|maxLength:5|minLength:3',
    'email' => 'required|email',
    'type' => 'required|in:user,admin',
    'name' => 'requiredIf:type,user,admin',
    'profilePic' => 'file|requiredIf:type,user,admin|fileSize:10KB|fileType:jpg,png,jpeg',
];
$validator->make($_POST, $_FILES, $rules);

$validator->validate();

OR Validate directly

$validator->validate($_POST, $_FILES, $rules);

Built With

Contributing

Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.

If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!

  1. Fork the Project
  2. Create your Feature Branch
  3. Commit your Changes
  4. Push to the Branch
  5. Open a Pull Request