|
| 1 | +<?php declare(strict_types=1); |
| 2 | + |
| 3 | +namespace Inhere\Validate\Locale; |
| 4 | + |
| 5 | +use Inhere\Validate\Validator\GlobalMessage; |
| 6 | + |
| 7 | +/** |
| 8 | + * Class LocaleZhCN |
| 9 | + * |
| 10 | + * @package Inhere\Validate\Locale |
| 11 | + */ |
| 12 | +class LocaleZhCN |
| 13 | +{ |
| 14 | + /** |
| 15 | + * Default error messages |
| 16 | + * |
| 17 | + * @var array |
| 18 | + */ |
| 19 | + public static $messages = [ |
| 20 | + // 'int' 'integer' |
| 21 | + 'integer' => [ |
| 22 | + '{attr} 必须是整数!', |
| 23 | + '{attr} 必须是整数并且最小值是 {min}', |
| 24 | + '{attr} 必须是整数并且值的范围必须在 {min} ~ {max}', |
| 25 | + ], |
| 26 | + // 'num' |
| 27 | + 'number' => [ |
| 28 | + '{attr} 必须是整数并且大于0!', |
| 29 | + '{attr} 必须是整数并且最小值是 {min}', |
| 30 | + '{attr} 必须是整数并且值的范围必须在 {min} ~ {max}', |
| 31 | + ], |
| 32 | + // 'bool', 'boolean', |
| 33 | + 'boolean' => '{attr} 必须是布尔类型!', |
| 34 | + 'float' => '{attr} 必须是浮点数!', |
| 35 | + 'url' => '{attr} is not a url address!', |
| 36 | + 'email' => '{attr} is not a email address!', |
| 37 | + 'date' => '{attr} is not a date format!', |
| 38 | + 'dateFormat' => '{attr} is not in a {value0} date format!', |
| 39 | + 'ip' => '{attr} is not IP address!', |
| 40 | + 'ipv4' => '{attr} is not a IPv4 address!', |
| 41 | + 'ipv6' => '{attr} is not a IPv6 address!', |
| 42 | + 'required' => 'parameter {attr} is required!', |
| 43 | + 'requiredIf' => 'parameter {attr} is required!', |
| 44 | + 'length' => [ |
| 45 | + '{attr} length validation is not through!', |
| 46 | + '{attr} must be an string/array and minimum length is {min}', |
| 47 | + '{attr} must be an string/array and length range {min} ~ {max}', |
| 48 | + ], |
| 49 | + // 'range', 'between' |
| 50 | + 'size' => [ |
| 51 | + '{attr} size validation is not through!', |
| 52 | + '{attr} must be an integer/string/array and minimum value/length is {min}', |
| 53 | + // '{attr} must be an integer/string/array and value/length range {min} ~ {max}', |
| 54 | + '{attr} must be in the range {min} ~ {max}', |
| 55 | + ], |
| 56 | + |
| 57 | + // 'lengthEq', 'sizeEq' |
| 58 | + 'fixedSize' => '{attr} length must is {value0}', |
| 59 | + |
| 60 | + 'eq' => '{attr} must be equals to {value0}', |
| 61 | + // 'different' |
| 62 | + 'ne' => '{attr} can not be equals to {value0}', |
| 63 | + 'min' => '{attr} minimum boundary is {value0}', |
| 64 | + 'max' => '{attr} maximum boundary is {value0}', |
| 65 | + 'lt' => '{attr} value must be less than {value0}', |
| 66 | + 'lte' => '{attr} value must be less than or equals to {value0}', |
| 67 | + 'gt' => '{attr} value must be greater than or equals to {value0}', |
| 68 | + 'gte' => '{attr} value must be greater than or equals to {value0}', |
| 69 | + |
| 70 | + // field compare |
| 71 | + 'eqField' => '{attr} value must be less than {value0}', |
| 72 | + 'neqField' => '{attr} value must be less than {value0}', |
| 73 | + 'ltField' => '{attr} value must be less than {value0}', |
| 74 | + 'lteField' => '{attr} value must be less than or equals to {value0}', |
| 75 | + 'gtField' => '{attr} value must be greater than {value0}', |
| 76 | + 'gteField' => '{attr} value must be greater than or equals to {value0}', |
| 77 | + |
| 78 | + // 'in', 'enum', |
| 79 | + 'enum' => '{attr} must in ({value0})', |
| 80 | + 'notIn' => '{attr} cannot in ({value0})', |
| 81 | + |
| 82 | + 'string' => [ |
| 83 | + '{attr} must be a string', |
| 84 | + '{attr} must be a string and minimum length be {min}', |
| 85 | + '{attr} must be a string and length range must be {min} ~ {max}', |
| 86 | + ], |
| 87 | + |
| 88 | + // 'regex', 'regexp', |
| 89 | + 'regexp' => '{attr} does not match the {value0} conditions', |
| 90 | + |
| 91 | + 'mustBe' => '{attr} must be equals to {value0}', |
| 92 | + 'notBe' => '{attr} can not be equals to {value0}', |
| 93 | + |
| 94 | + 'compare' => '{attr} must be equals to {value0}', |
| 95 | + 'same' => '{attr} must be equals to {value0}', |
| 96 | + |
| 97 | + 'isArray' => '{attr} must be an array', |
| 98 | + 'isMap' => '{attr} must be an array and is key-value format', |
| 99 | + 'isList' => '{attr} must be an array of nature', |
| 100 | + 'intList' => '{attr} must be an array and value is all integers', |
| 101 | + 'numList' => '{attr} must be an array and value is all numbers', |
| 102 | + 'strList' => '{attr} must be an array and value is all strings', |
| 103 | + 'arrList' => '{attr} must be an array and value is all arrays', |
| 104 | + |
| 105 | + 'each' => '{attr} each value must be through the "{value0}" verify', |
| 106 | + 'hasKey' => '{attr} must be contains the key {value0}', |
| 107 | + 'distinct' => 'there should not be duplicate keys in the {attr}', |
| 108 | + |
| 109 | + 'json' => '{attr} must be an json string', |
| 110 | + |
| 111 | + 'file' => '{attr} must be an uploaded file', |
| 112 | + 'image' => '{attr} must be an uploaded image file', |
| 113 | + |
| 114 | + 'callback' => '{attr} don\'t pass the test and verify!', |
| 115 | + '__default' => '{attr} validation is not through!', |
| 116 | + ]; |
| 117 | + |
| 118 | + /** |
| 119 | + * register to global message |
| 120 | + */ |
| 121 | + public static function register(): void |
| 122 | + { |
| 123 | + GlobalMessage::setMessages(self::$messages); |
| 124 | + } |
| 125 | +} |
0 commit comments