【发布时间】:2015-09-18 07:59:51
【问题描述】:
我在结帐产品增值税验证时遇到自定义验证问题。
但我运行时出现此错误:
找不到类“App\Providers\ValidationExtensionS Service Provider”。
谁能帮我解决这个问题。
我已在此处附加了我的 valadatorextended.php 文件:
namespace App\Services;
use App\Services\ValidatorExtended;
use Illuminate\Support\ServiceProvider;
use Illuminate\Validation\Validator as IlluminateValidator;
class ValidatorExtended extends IlluminateValidator {
private $_custom_messages = array(
"vat" => "The :attribute is not a valid VAT.",
//place for more customized messages
);
public function __construct( $translator, $data, $rules, $messages = array(), $customAttributes = array() ) {
parent::__construct( $translator, $data, $rules, $messages, $customAttributes );
$this->_set_custom_stuff();
}
protected function _set_custom_stuff() {
//setup our custom error messages
$this->setCustomMessages( $this->_custom_messages );
}
protected function validateVat( $attribute, $value ) {
// You can extend your RegEx with other Countries, if you like
return (bool) preg_match( "/((DK|FI|HU|LU|MT|SI)(-)?\d{8})|((BE|EE|DE|EL|LT|PT)(-)?\d{9})|((PL|SK)(-)?\d{10})|((IT|LV)(-)?\d{11})|((LT|SE)(-)?\d{12})|(AT(-)?U\d{8})|(CY(-)?\d{8}[A-Z])|(CZ(-)?\d{8,10})|(FR(-)?[\dA-HJ-NP-Z]{2}\d{9})|(IE(-)?\d[A-Z\d]\d{5}[A-Z])|(NL(-)?\d{9}B\d{2})|(ES(-)?[A-Z\d]\d{7}[A-Z\d])/", $value );
}
//place for more protected functions for other custom validations
}
【问题讨论】:
标签: php laravel-4 custom-validators