栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > PHP

Validator.php-5

PHP 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

Validator.php-5

 

    protected function validateRequiredWith($attribute, $value, $parameters)

    {

        if (! $this->allFailingRequired($parameters)) {// if all of them just be require

            return $this->validateRequired($attribute, $value);// return a validateRequired

        }//something is wrong

 

        return true;

    }//validate that an attribute exists when any other attribute exists

 

   

    protected function validateRequiredWithAll($attribute, $value, $parameters)

    {

        if (! $this->anyFailingRequired($parameters)) {

            return $this->validateRequired($attribute, $value);

        }// validaterequired

 

        return true;

    }// too simple in this function

 

   

    protected function validateRequiredWithout($attribute, $value, $parameters)

    {

        if ($this->anyFailingRequired($parameters)) {

            return $this->validateRequired($attribute, $value);

        }

 

        return true;

    }//Validate that an attribute exists when another attribute does not.

 

   

    protected function validateRequiredWithoutAll($attribute, $value, $parameters)

    {

        if ($this->allFailingRequired($parameters)) {

            return $this->validateRequired($attribute, $value);

        }

 

        return true;

    }//validate that an attribute exists when all other attributes do not

 

   

    protected function validateRequiredIf($attribute, $value, $parameters)

    {//Validate that an attribute exists when another attribute has a given value.

        $this->requireParameterCount(2, $parameters, 'required_if');// a user function

 

        $data = Arr::get($this->data, $parameters[0]);// all of this arr::get

 

        $values = array_slice($parameters, 1);// use this sys function to get this value

       // just like get the other array about use this function that is array_pop

 

        if (in_array($data, $values)) {

            return $this->validateRequired($attribute, $value);

        }// if this value in this value

 

        return true;// default just a true return

    }

 

   

    protected function validateRequiredUnless($attribute, $value, $parameters)

    {//validate that an attribute exists when another attribute does not have a given value

        $this->requireParameterCount(2, $parameters, 'required_unless');

// get parameter Count number , that is a user function

        $data = Arr::get($this->data, $parameters[0]);// just get this array value use the key

 

        $values = array_slice($parameters, 1);// get other collection

 

        if (! in_array($data, $values)) {// if in the data

            return $this->validateRequired($attribute, $value);

        }//determine it is right

 

        return true;//default it is true

    }

 

   

    protected function getPresentCount($attributes)

    {// function name that is get Present Count

        $count = 0;// set the default number

 

        foreach ($attributes as $key) {// loop this attribute

            if (Arr::get($this->data, $key) || Arr::get($this->files, $key)) {

                $count++;

            }// if it is can get something by data or bay files ,return count++

        }

 

        return $count;

    }// get the number in this list now

 

   

    protected function validateConfirmed($attribute, $value)

    {// first this just a wrap

        return $this->validateSame($attribute, $value, [$attribute.'_/confirm/iation']);

       // validate Same has three parameters

    }//validate that an attribute has a matching /confirm/iation

 

   

    protected function validateSame($attribute, $value, $parameters)

    {

        $this->requireParameterCount(1, $parameters, 'same');//require ParameterCount

 

        $other = Arr::get($this->data, $parameters[0]);// Arr::get

 

        return isset($other) && $value === $other;//return it is other

    }//validate that two attributes match

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/230107.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号