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

Validator.php-11

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

Validator.php-11

protected function checkDateTimeOrder($format, $before, $after){    $before = $this->getDateTimeWithOptionalFormat($format, $before);// format it     $after = $this->getDateTimeWithOptionalFormat($format, $after);// format after     return ($before && $after) && ($after > $before);// a big logic}// get two date/time strings, check that one is after the other. protected function getDateTimeWithOptionalFormat($format, $value){//Get a DateTime instance from a sting.    $date = DateTime::createFromFormat($format, $value);//Date::createFromFormat     if ($date) {// if date        return $date;    }     try {// return new DateTime        return new DateTime($value);    } catch (Exception $e) {        // do nothing    }} protected function validateTimezone($attribute, $value){    try {        new DateTimeZone($value);    } catch (Exception $e) {        return false;    }     return true;}//validate timezone protected function getDateFormat($attribute){    if ($result = $this->getRule($attribute, 'DateFormat')) {        return $result[1][0];    }}// Get the date format from an attribute if it has one. protected function getMessage($attribute, $rule){    $lowerRule = Str::snake($rule);// use snake method to get this you  want     $inlineMessage = $this->getInlineMessage($attribute, $lowerRule);// get message     // First we will retrieve the custom message for the validation rule if one    // exists. If a custom validation message is being used we'll return the    // custom message, otherwise we'll keep searching for a valid message.    if (! is_null($inlineMessage)) {        return $inlineMessage;    }// if it is a good message     $customKey = "validation.custom.{$attribute}.{$lowerRule}";// this can  get a good key     $customMessage = $this->getCustomMessageFromTranslator($customKey);     // First we check for a custom defined validation message for the attribute    // and rule. This allows the developer to specify specific messages for    // only some attributes and rules that need to get specially formed.    if ($customMessage !== $customKey) {        return $customMessage;    }// return the custom message     // If the rule being validated is a "size" rule, we will need to gather the    // specific error message for the type of attribute being validated such    // as a number, file or string which all have different message types.    elseif (in_array($rule, $this->sizeRules)) {        return $this->getSizeMessage($attribute, $rule);    }// specific error     // Finally, if no developer specified messages have been set, and no other    // special messages apply for this rule, we will just pull the default    // messages out of the translator service for this validation rule.    $key = "validation.{$lowerRule}";     if ($key != ($value = $this->translator->trans($key))) {        return $value;    }// just message     return $this->getInlineMessage(        $attribute, $lowerRule, $this->fallbackMessages    ) ?: $key;// return key}

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

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

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