Code Monkey home page Code Monkey logo

seequest's Introduction

PHP Request Validator

Latest Stable Version Total Downloads Build Status StyleCI PHP-Eye

Validate requests in easiest way!

Install

`composer require mvaliolahi/seequest`
usage
$validator = new SeeQuest('en');

$result = $validation->check($request, [
    'name' => 'required',
    'email' => 'required|email'
    'age'=> 'required|between:1,25',
    'score' => 'min:10',
    'high_score'=> 'max:600' 
]);

$err = $validator->getErrors();
Create custom validator

Create a class and extends from Mvaliolahi\SeeQuest\Contracts\Validator, it done!

just implement validate() method.

you have access to :

Request => $this->request
Attribute => $this->attribute
Value => $this->value
Rule => $this->rule
Rule-Option => $this->option
example:
<?php

namespace Mvaliolahi\SeeQuest\Validators;


use Mvaliolahi\SeeQuest\Contracts\Validator;

class Between extends Validator
{
    public $alias = 'between';

    public function validate()
    {
        $number = explode(',', $this->option);

        if (!($this->value >= $number[0] && $this->value <= $number[1])) {
            return $this->message();
        }
    }

    public function message()
    {
        return $this->translation->of($this->alias, [
            'attribute' => $this->attribute,
            'option' => $this->option,
        ]);
    }
}

After define your custom validator you should pass it to the Validator class:

$validator = new SeeQuest('en', [ BetweenSample::class ]);

Form Request

There is another class to create FormRequest, its very simple! you can use it to create amazing validation form! just look at the source code.

seequest's People

Contributors

mvaliolahi avatar

Stargazers

 avatar  avatar

Watchers

 avatar

seequest's Issues

Mutator

It is a good idea to have something like this:

'email' => 'required|email|unique:users,mutator=\App\Helpers\Validation\Mutators\LowercaseTrim::class',

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.