diff --git a/README.md b/README.md index 8e75066..0852d71 100644 --- a/README.md +++ b/README.md @@ -116,15 +116,13 @@ You can set the Translations Root Path before creating an instance of `Validator Validator::translationsRootPath(__DIR__ . '/'); ``` -Here's an example code for setting Translations Root Path and Language: [SetTranslationsRootPath.php](examples/SetTranslationsRootPath.php) - You can also set the Language before creating an instance of `Validator`: ```php // Set lang: 'en' as default (optional) Validator::lang('ja'); ``` -Here's an example code for setting Language: [SetLang.php](examples/SetLang.php) +Here's an example code for setting Translations Root Path and Language: [SetTranslationsRootPath.php](examples/SetTranslationsRootPath.php) ### 5.3. Using Password Rule Object @@ -138,7 +136,19 @@ $validator = Validator::make( rules: [ 'password' => [ 'required', - Password::min(8), + Password::min(8) + ->max(16) + // at least one letter + ->letters() + // at least one uppercase + // and at least one lowercase letter + ->mixedCase() + // at least one number + ->numbers() + // at least one symbol + ->symbols() + // not in a data leak + ->uncompromised(), ], ], ); @@ -153,6 +163,7 @@ Here's an example code for using `Password` rule object: [ValidatePassword.php]( You can validate files using Laravel's `File` rule object. ```php +use Illuminate\Validation\Rule; use Macocci7\PurephpValidation\Rules\FileWrapper as File; use Symfony\Component\HttpFoundation\File\File as SymfonyFile; @@ -166,7 +177,13 @@ $validator = Validator::make( 'photo' => [ 'required', File::image() - ->max(1024), // kilo bytes + ->min(10) // kilo bytes + ->max(144) // kilo bytes + ->dimensions( + Rule::dimensions() + ->maxWidth(200) // pix + ->maxHeight(300) // pix + ), ], ], ); @@ -180,7 +197,6 @@ Here's an example code for using Laravel's `File` rule object: [ValidateFile.php - [BasicUsage.php](examples/BasicUsage.php) - [SetTranslationsRootPath.php](examples/SetTranslationsRootPath.php) -- [SetLang.php](examples/SetLang.php) - [ValidatePassword.php](examples/ValidatePassword.php) - [ValidateFile.php](examples/ValidateFile.php) diff --git a/composer.json b/composer.json index 1e9db7a..94206a0 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { "name": "macocci7/purephp-validation", "description": "illuminate/validation wrapper for pure php.", - "version": "0.0.1", + "version": "0.0.2", "type": "library", "license": "MIT", "autoload": { diff --git a/examples/SetLang.php b/examples/SetLang.php deleted file mode 100644 index d0ebd1d..0000000 --- a/examples/SetLang.php +++ /dev/null @@ -1,36 +0,0 @@ - 'fo', - 'email' => 'foo', - 'pionts' => -1, -]; - -// Valiation Rules -$rules = [ - 'name' => 'required|string|min:3|max:10', - 'email' => 'required|string|email:rfc,dns', - 'pionts' => 'required|int|min:1', -]; - -// Set Tranlations Root Path -// - 'lang/' folder must be placed under the path. -Validator::translationsRootPath(__DIR__ . '/'); - -// Set lang: 'en' as default -Validator::lang('ja'); - -// Validation -$validator = Validator::make($user, $rules); - -// Checking result -if ($validator->fails()) { - var_dump($validator->errors()->messages()); -} else { - echo "🎊 Passed 🎉" . PHP_EOL; -} diff --git a/examples/ValidateFile.php b/examples/ValidateFile.php index 0472234..fdc7c13 100644 --- a/examples/ValidateFile.php +++ b/examples/ValidateFile.php @@ -20,11 +20,12 @@ 'photo' => [ 'required', File::image() - //File::types(['jpg', 'png']) - ->min(10) - ->max(144) + ->min(10) // kilo bytes + ->max(144) // kilo bytes ->dimensions( - Rule::dimensions()->maxWidth(200)->maxHeight(300) + Rule::dimensions() + ->maxWidth(200) // pix + ->maxHeight(300) // pix ), ], ]; diff --git a/examples/ValidatePassword.php b/examples/ValidatePassword.php index fefb955..4970a49 100644 --- a/examples/ValidatePassword.php +++ b/examples/ValidatePassword.php @@ -20,10 +20,16 @@ 'required', Password::min(8) ->max(16) + // at least one letter ->letters() + // at least one uppercase + // and at least one lowercase letter ->mixedCase() + // at least one number ->numbers() + // at least one symbol ->symbols() + // not in a data leak ->uncompromised(), ], ]; diff --git a/examples/lang/en/validation.php b/examples/lang/en/validation.php index c2a34e4..c3e94e1 100644 --- a/examples/lang/en/validation.php +++ b/examples/lang/en/validation.php @@ -1,68 +1,193 @@ 'The :attribute must be accepted.', - 'active_url' => 'The :attribute is not a valid URL.', - 'after' => 'The :attribute must be a date after :date.', - 'alpha' => 'The :attribute may only contain letters.', - 'alpha_dash' => 'The :attribute may only contain letters, numbers, and dashes.', - 'alpha_num' => 'The :attribute may only contain letters and numbers.', - 'array' => 'The :attribute must be an array.', - 'before' => 'The :attribute must be a date before :date.', + + /* + |-------------------------------------------------------------------------- + | Validation Language Lines + |-------------------------------------------------------------------------- + | + | The following language lines contain the default error messages used by + | the validator class. Some of these rules have multiple versions such + | as the size rules. Feel free to tweak each of these messages here. + | + */ + + 'accepted' => 'The :attribute field must be accepted.', + 'accepted_if' => 'The :attribute field must be accepted when :other is :value.', + 'active_url' => 'The :attribute field must be a valid URL.', + 'after' => 'The :attribute field must be a date after :date.', + 'after_or_equal' => 'The :attribute field must be a date after or equal to :date.', + 'alpha' => 'The :attribute field must only contain letters.', + 'alpha_dash' => 'The :attribute field must only contain letters, numbers, dashes, and underscores.', + 'alpha_num' => 'The :attribute field must only contain letters and numbers.', + 'array' => 'The :attribute field must be an array.', + 'ascii' => 'The :attribute field must only contain single-byte alphanumeric characters and symbols.', + 'before' => 'The :attribute field must be a date before :date.', + 'before_or_equal' => 'The :attribute field must be a date before or equal to :date.', 'between' => [ - 'numeric' => 'The :attribute must be between :min and :max.', - 'file' => 'The :attribute must be between :min and :max kilobytes.', - 'string' => 'The :attribute must be between :min and :max characters.', - 'array' => 'The :attribute must have between :min and :max items.', + 'array' => 'The :attribute field must have between :min and :max items.', + 'file' => 'The :attribute field must be between :min and :max kilobytes.', + 'numeric' => 'The :attribute field must be between :min and :max.', + 'string' => 'The :attribute field must be between :min and :max characters.', ], 'boolean' => 'The :attribute field must be true or false.', - 'confirmed' => 'The :attribute confirmation does not match.', - 'date' => 'The :attribute is not a valid date.', - 'date_format' => 'The :attribute does not match the format :format.', - 'different' => 'The :attribute and :other must be different.', - 'digits' => 'The :attribute must be :digits digits.', - 'digits_between' => 'The :attribute must be between :min and :max digits.', - 'email' => 'The :attribute must be a valid email address.', + 'can' => 'The :attribute field contains an unauthorized value.', + 'confirmed' => 'The :attribute field confirmation does not match.', + 'current_password' => 'The password is incorrect.', + 'date' => 'The :attribute field must be a valid date.', + 'date_equals' => 'The :attribute field must be a date equal to :date.', + 'date_format' => 'The :attribute field must match the format :format.', + 'decimal' => 'The :attribute field must have :decimal decimal places.', + 'declined' => 'The :attribute field must be declined.', + 'declined_if' => 'The :attribute field must be declined when :other is :value.', + 'different' => 'The :attribute field and :other must be different.', + 'digits' => 'The :attribute field must be :digits digits.', + 'digits_between' => 'The :attribute field must be between :min and :max digits.', + 'dimensions' => 'The :attribute field has invalid image dimensions.', + 'distinct' => 'The :attribute field has a duplicate value.', + 'doesnt_end_with' => 'The :attribute field must not end with one of the following: :values.', + 'doesnt_start_with' => 'The :attribute field must not start with one of the following: :values.', + 'email' => 'The :attribute field must be a valid email address.', + 'ends_with' => 'The :attribute field must end with one of the following: :values.', + 'enum' => 'The selected :attribute is invalid.', 'exists' => 'The selected :attribute is invalid.', - 'filled' => 'The :attribute field is required.', - 'image' => 'The :attribute must be an image.', + 'extensions' => 'The :attribute field must have one of the following extensions: :values.', + 'file' => 'The :attribute field must be a file.', + 'filled' => 'The :attribute field must have a value.', + 'gt' => [ + 'array' => 'The :attribute field must have more than :value items.', + 'file' => 'The :attribute field must be greater than :value kilobytes.', + 'numeric' => 'The :attribute field must be greater than :value.', + 'string' => 'The :attribute field must be greater than :value characters.', + ], + 'gte' => [ + 'array' => 'The :attribute field must have :value items or more.', + 'file' => 'The :attribute field must be greater than or equal to :value kilobytes.', + 'numeric' => 'The :attribute field must be greater than or equal to :value.', + 'string' => 'The :attribute field must be greater than or equal to :value characters.', + ], + 'hex_color' => 'The :attribute field must be a valid hexadecimal color.', + 'image' => 'The :attribute field must be an image.', 'in' => 'The selected :attribute is invalid.', - 'integer' => 'The :attribute must be an integer.', - 'ip' => 'The :attribute must be a valid IP address.', - 'json' => 'The :attribute must be a valid JSON string.', + 'in_array' => 'The :attribute field must exist in :other.', + 'integer' => 'The :attribute field must be an integer.', + 'ip' => 'The :attribute field must be a valid IP address.', + 'ipv4' => 'The :attribute field must be a valid IPv4 address.', + 'ipv6' => 'The :attribute field must be a valid IPv6 address.', + 'json' => 'The :attribute field must be a valid JSON string.', + 'list' => 'The :attribute field must be a list.', + 'lowercase' => 'The :attribute field must be lowercase.', + 'lt' => [ + 'array' => 'The :attribute field must have less than :value items.', + 'file' => 'The :attribute field must be less than :value kilobytes.', + 'numeric' => 'The :attribute field must be less than :value.', + 'string' => 'The :attribute field must be less than :value characters.', + ], + 'lte' => [ + 'array' => 'The :attribute field must not have more than :value items.', + 'file' => 'The :attribute field must be less than or equal to :value kilobytes.', + 'numeric' => 'The :attribute field must be less than or equal to :value.', + 'string' => 'The :attribute field must be less than or equal to :value characters.', + ], + 'mac_address' => 'The :attribute field must be a valid MAC address.', 'max' => [ - 'numeric' => 'The :attribute may not be greater than :max.', - 'file' => 'The :attribute may not be greater than :max kilobytes.', - 'string' => 'The :attribute may not be greater than :max characters.', - 'array' => 'The :attribute may not have more than :max items.', + 'array' => 'The :attribute field must not have more than :max items.', + 'file' => 'The :attribute field must not be greater than :max kilobytes.', + 'numeric' => 'The :attribute field must not be greater than :max.', + 'string' => 'The :attribute field must not be greater than :max characters.', ], - 'mimes' => 'The :attribute must be a file of type: :values.', + 'max_digits' => 'The :attribute field must not have more than :max digits.', + 'mimes' => 'The :attribute field must be a file of type: :values.', + 'mimetypes' => 'The :attribute field must be a file of type: :values.', 'min' => [ - 'numeric' => 'The :attribute must be at least :min.', - 'file' => 'The :attribute must be at least :min kilobytes.', - 'string' => 'The :attribute must be at least :min characters.', - 'array' => 'The :attribute must have at least :min items.', + 'array' => 'The :attribute field must have at least :min items.', + 'file' => 'The :attribute field must be at least :min kilobytes.', + 'numeric' => 'The :attribute field must be at least :min.', + 'string' => 'The :attribute field must be at least :min characters.', ], + 'min_digits' => 'The :attribute field must have at least :min digits.', + 'missing' => 'The :attribute field must be missing.', + 'missing_if' => 'The :attribute field must be missing when :other is :value.', + 'missing_unless' => 'The :attribute field must be missing unless :other is :value.', + 'missing_with' => 'The :attribute field must be missing when :values is present.', + 'missing_with_all' => 'The :attribute field must be missing when :values are present.', + 'multiple_of' => 'The :attribute field must be a multiple of :value.', 'not_in' => 'The selected :attribute is invalid.', - 'numeric' => 'The :attribute must be a number.', + 'not_regex' => 'The :attribute field format is invalid.', + 'numeric' => 'The :attribute field must be a number.', + 'password' => [ + 'letters' => 'The :attribute field must contain at least one letter.', + 'mixed' => 'The :attribute field must contain at least one uppercase and one lowercase letter.', + 'numbers' => 'The :attribute field must contain at least one number.', + 'symbols' => 'The :attribute field must contain at least one symbol.', + 'uncompromised' => 'The given :attribute has appeared in a data leak. Please choose a different :attribute.', + ], 'present' => 'The :attribute field must be present.', - 'regex' => 'The :attribute format is invalid.', + 'present_if' => 'The :attribute field must be present when :other is :value.', + 'present_unless' => 'The :attribute field must be present unless :other is :value.', + 'present_with' => 'The :attribute field must be present when :values is present.', + 'present_with_all' => 'The :attribute field must be present when :values are present.', + 'prohibited' => 'The :attribute field is prohibited.', + 'prohibited_if' => 'The :attribute field is prohibited when :other is :value.', + 'prohibited_unless' => 'The :attribute field is prohibited unless :other is in :values.', + 'prohibits' => 'The :attribute field prohibits :other from being present.', + 'regex' => 'The :attribute field format is invalid.', 'required' => 'The :attribute field is required.', + 'required_array_keys' => 'The :attribute field must contain entries for: :values.', 'required_if' => 'The :attribute field is required when :other is :value.', + 'required_if_accepted' => 'The :attribute field is required when :other is accepted.', + 'required_if_declined' => 'The :attribute field is required when :other is declined.', 'required_unless' => 'The :attribute field is required unless :other is in :values.', 'required_with' => 'The :attribute field is required when :values is present.', - 'required_with_all' => 'The :attribute field is required when :values is present.', + 'required_with_all' => 'The :attribute field is required when :values are present.', 'required_without' => 'The :attribute field is required when :values is not present.', 'required_without_all' => 'The :attribute field is required when none of :values are present.', - 'same' => 'The :attribute and :other must match.', + 'same' => 'The :attribute field must match :other.', 'size' => [ - 'numeric' => 'The :attribute must be :size.', - 'file' => 'The :attribute must be :size kilobytes.', - 'string' => 'The :attribute must be :size characters.', - 'array' => 'The :attribute must contain :size items.', + 'array' => 'The :attribute field must contain :size items.', + 'file' => 'The :attribute field must be :size kilobytes.', + 'numeric' => 'The :attribute field must be :size.', + 'string' => 'The :attribute field must be :size characters.', ], - 'string' => 'The :attribute must be a string.', - 'timezone' => 'The :attribute must be a valid zone.', + 'starts_with' => 'The :attribute field must start with one of the following: :values.', + 'string' => 'The :attribute field must be a string.', + 'timezone' => 'The :attribute field must be a valid timezone.', 'unique' => 'The :attribute has already been taken.', - 'url' => 'The :attribute format is invalid.' + 'uploaded' => 'The :attribute failed to upload.', + 'uppercase' => 'The :attribute field must be uppercase.', + 'url' => 'The :attribute field must be a valid URL.', + 'ulid' => 'The :attribute field must be a valid ULID.', + 'uuid' => 'The :attribute field must be a valid UUID.', + + /* + |-------------------------------------------------------------------------- + | Custom Validation Language Lines + |-------------------------------------------------------------------------- + | + | Here you may specify custom validation messages for attributes using the + | convention "attribute.rule" to name the lines. This makes it quick to + | specify a specific custom language line for a given attribute rule. + | + */ + + 'custom' => [ + 'attribute-name' => [ + 'rule-name' => 'custom-message', + ], + ], + + /* + |-------------------------------------------------------------------------- + | Custom Validation Attributes + |-------------------------------------------------------------------------- + | + | The following language lines are used to swap our attribute placeholder + | with something more reader friendly such as "E-Mail Address" instead + | of "email". This simply helps us make our message more expressive. + | + */ + + 'attributes' => [], + ]; diff --git a/examples/lang/ja/validation.php b/examples/lang/ja/validation.php index 12407a4..aeb945b 100644 --- a/examples/lang/ja/validation.php +++ b/examples/lang/ja/validation.php @@ -2,130 +2,163 @@ return [ - /* - |-------------------------------------------------------------------------- - | バリデーション言語行 - |-------------------------------------------------------------------------- - | - | 以下の言語行はバリデタークラスにより使用されるデフォルトのエラー - | メッセージです。サイズルールのようにいくつかのバリデーションを - | 持っているものもあります。メッセージはご自由に調整してください。 - | - */ + /* メッセージの内容がご自身のアプリに適さない場合には、必要に応じて修正願います */ - 'accepted' => ':attributeを承認してください。', - 'active_url' => ':attributeが有効なURLではありません。', - 'after' => ':attributeには、:dateより後の日付を指定してください。', - 'after_or_equal' => ':attributeには、:date以降の日付を指定してください。', - 'alpha' => ':attributeはアルファベットのみがご利用できます。', - 'alpha_dash' => ':attributeはアルファベットとダッシュ(-)及び下線(_)がご利用できます。', - 'alpha_num' => ':attributeはアルファベット数字がご利用できます。', - 'array' => ':attributeは配列でなくてはなりません。', - 'before' => ':attributeには、:dateより前の日付をご利用ください。', - 'before_or_equal' => ':attributeには、:date以前の日付をご利用ください。', - 'between' => [ + 'accepted' => ':attributeを承認してください。', + 'accepted_if' => ':otherが:valueの場合、:attributeを承認してください。', + 'active_url' => ':attributeが有効なURLではありません。', + 'after' => ':attributeには、:dateより後の日付を指定してください。', + 'after_or_equal' => ':attributeには、:date以降の日付を指定してください。', + 'alpha' => ':attributeはアルファベットのみがご利用できます。', + 'alpha_dash' => ':attributeはアルファベットとダッシュ(-)及び下線(_)がご利用できます。', + 'alpha_num' => ':attributeはアルファベット数字がご利用できます。', + 'array' => ':attributeは配列でなくてはなりません。', + 'ascii' => ':attributeは半角の英数字や記号のみで指定してください。', + 'before' => ':attributeには、:dateより前の日付をご利用ください。', + 'before_or_equal' => ':attributeには、:date以前の日付をご利用ください。', + 'between' => [ 'numeric' => ':attributeは、:minから:maxの間で指定してください。', - 'file' => ':attributeは、:min kBから、:max kBの間で指定してください。', - 'string' => ':attributeは、:min文字から、:max文字の間で指定してください。', - 'array' => ':attributeは、:min個から:max個の間で指定してください。', + 'file' => ':attributeは、:min kbから、:max kbの間で指定してください。', + 'string' => ':attributeは、:min文字から、:max文字の間で指定してください。', + 'array' => ':attributeは、:min個から:max個の間で指定してください。', ], - 'boolean' => ':attributeは、trueかfalseを指定してください。', - 'confirmed' => ':attributeと、確認フィールドとが、一致していません。', - 'date' => ':attributeには有効な日付を指定してください。', - 'date_equals' => ':attributeには、:dateと同じ日付けを指定してください。', - 'date_format' => ':attributeは:format形式で指定してください。', - 'different' => ':attributeと:otherには、異なった内容を指定してください。', - 'digits' => ':attributeは:digits桁で指定してください。', - 'digits_between' => ':attributeは:min桁から:max桁の間で指定してください。', - 'dimensions' => ':attributeの図形サイズが正しくありません。', - 'distinct' => ':attributeには異なった値を指定してください。', - 'email' => ':attributeには、有効なメールアドレスを指定してください。', - 'ends_with' => ':attributeには、:valuesのどれかで終わる値を指定してください。', - 'exists' => '選択された:attributeは正しくありません。', - 'file' => ':attributeにはファイルを指定してください。', - 'filled' => ':attributeに値を指定してください。', - 'gt' => [ + 'boolean' => ':attributeは、trueかfalseを指定してください。', + 'can' => ':attributeに権限のない値が含まれています。', + 'confirmed' => ':attributeと確認フィールドが一致していません。', + 'current_password' => 'パスワードが正しくありません。', + 'date' => ':attributeには有効な日付を指定してください。', + 'date_equals' => ':attributeには、:dateと同じ日付けを指定してください。', + 'date_format' => ':attributeは:format形式で指定してください。', + 'decimal' => ':attributeは、小数点以下:decimal桁の数字を指定してください。', + 'declined' => ':attributeは、拒否する指定をしてください。', + 'declined_if' => ':attributeは、:otherが:valueの時は、拒否する指定をしてください。', + 'different' => ':attributeと:otherには、異なった内容を指定してください。', + 'digits' => ':attributeは:digits桁で指定してください。', + 'digits_between' => ':attributeは:min桁から:max桁の間で指定してください。', + 'dimensions' => ':attributeの図形サイズが正しくありません。', + 'distinct' => ':attributeには異なった値を指定してください。', + 'doesnt_end_with' => ':attributeは、:values以外の値で終わるように指定してください。', + 'doesnt_start_with' => ':attributeは、:values以外の値で始まるように指定してください。', + 'email' => ':attributeには、有効なメールアドレスを指定してください。', + 'ends_with' => ':attributeには、:valuesのどれかで終わる値を指定してください。', + 'enum' => '選択された:attributeは正しくありません。', + 'exists' => '選択された:attributeは正しくありません。', + 'extensions' => ':attributeは、:valuesの拡張子を指定してください。', + 'file' => ':attributeにはファイルを指定してください。', + 'filled' => ':attributeに値を指定してください。', + 'gt' => [ 'numeric' => ':attributeには、:valueより大きな値を指定してください。', - 'file' => ':attributeには、:value kBより大きなファイルを指定してください。', - 'string' => ':attributeは、:value文字より長く指定してください。', - 'array' => ':attributeには、:value個より多くのアイテムを指定してください。', + 'file' => ':attributeには、:value kbより大きなファイルを指定してください。', + 'string' => ':attributeは、:value文字より長く指定してください。', + 'array' => ':attributeには、:value個より多くのアイテムを指定してください。', ], - 'gte' => [ + 'gte' => [ 'numeric' => ':attributeには、:value以上の値を指定してください。', - 'file' => ':attributeには、:value kB以上のファイルを指定してください。', - 'string' => ':attributeは、:value文字以上で指定してください。', - 'array' => ':attributeには、:value個以上のアイテムを指定してください。', + 'file' => ':attributeには、:value kb以上のファイルを指定してください。', + 'string' => ':attributeは、:value文字以上で指定してください。', + 'array' => ':attributeには、:value個以上のアイテムを指定してください。', ], - 'image' => ':attributeには画像ファイルを指定してください。', - 'in' => '選択された:attributeは正しくありません。', - 'in_array' => ':attributeには:otherの値を指定してください。', - 'integer' => ':attributeは整数で指定してください。', - 'ip' => ':attributeには、有効なIPアドレスを指定してください。', - 'ipv4' => ':attributeには、有効なIPv4アドレスを指定してください。', - 'ipv6' => ':attributeには、有効なIPv6アドレスを指定してください。', - 'json' => ':attributeには、有効なJSON文字列を指定してください。', - 'lt' => [ + 'hex_color' => ':attributeには、有効な16進数の色を指定してください。', + 'image' => ':attributeには画像ファイルを指定してください。', + 'in' => '選択された:attributeは正しくありません。', + 'in_array' => ':attributeには:otherの値を指定してください。', + 'integer' => ':attributeは整数で指定してください。', + 'ip' => ':attributeには、有効なIPアドレスを指定してください。', + 'ipv4' => ':attributeには、有効なIPv4アドレスを指定してください。', + 'ipv6' => ':attributeには、有効なIPv6アドレスを指定してください。', + 'json' => ':attributeには、有効なJSON文字列を指定してください。', + 'list' => ':attributeには、一覧を指定してください。', + 'lowercase' => ':attributeは、小文字のみで指定してください。', + 'lt' => [ 'numeric' => ':attributeには、:valueより小さな値を指定してください。', - 'file' => ':attributeには、:value kBより小さなファイルを指定してください。', - 'string' => ':attributeは、:value文字より短く指定してください。', - 'array' => ':attributeには、:value個より少ないアイテムを指定してください。', + 'file' => ':attributeには、:value kbより小さなファイルを指定してください。', + 'string' => ':attributeは、:value文字より短く指定してください。', + 'array' => ':attributeには、:value個より少ないアイテムを指定してください。', ], - 'lte' => [ + 'lte' => [ 'numeric' => ':attributeには、:value以下の値を指定してください。', - 'file' => ':attributeには、:value kB以下のファイルを指定してください。', - 'string' => ':attributeは、:value文字以下で指定してください。', - 'array' => ':attributeには、:value個以下のアイテムを指定してください。', + 'file' => ':attributeには、:value kb以下のファイルを指定してください。', + 'string' => ':attributeは、:value文字以下で指定してください。', + 'array' => ':attributeには、:value個以下のアイテムを指定してください。', ], - 'max' => [ + 'mac_address' => ':attributeには、有効なMACアドレスを指定してください。', + 'max' => [ 'numeric' => ':attributeには、:max以下の数字を指定してください。', - 'file' => ':attributeには、:max kB以下のファイルを指定してください。', - 'string' => ':attributeは、:max文字以下で指定してください。', - 'array' => ':attributeは:max個以下指定してください。', + 'file' => ':attributeには、:max kb以下のファイルを指定してください。', + 'string' => ':attributeは、:max文字以下で指定してください。', + 'array' => ':attributeは:max個以下指定してください。', ], - 'mimes' => ':attributeには:valuesタイプのファイルを指定してください。', - 'mimetypes' => ':attributeには:valuesタイプのファイルを指定してください。', - 'min' => [ + 'max_digits' => ':attributeは、:max桁以下で指定してください。', + 'mimes' => ':attributeには:valuesタイプのファイルを指定してください。', + 'mimetypes' => ':attributeには:valuesタイプのファイルを指定してください。', + 'min' => [ 'numeric' => ':attributeには、:min以上の数字を指定してください。', - 'file' => ':attributeには、:min kB以上のファイルを指定してください。', - 'string' => ':attributeは、:min文字以上で指定してください。', - 'array' => ':attributeは:min個以上指定してください。', + 'file' => ':attributeには、:min kb以上のファイルを指定してください。', + 'string' => ':attributeは、:min文字以上で指定してください。', + 'array' => ':attributeは:min個以上指定してください。', + ], + 'min_digits' => ':attributeは、:min桁以上で指定してください。', + 'missing' => ':attributeは存在してはいけません。', + 'missing_if' => ':otherが:valueの場合、:attributeは存在してはいけません。', + 'missing_unless' => ':otherが:valueでない場合、:attributeは存在してはいけません。', + 'missing_with' => ':valuesを指定する場合は、:attributeは存在してはいけません。 ', + 'missing_with_all' => ':valuesを指定する場合は、:attributeは存在してはいけません。 ', + 'multiple_of' => ':attributeには、:valueの倍数を指定してください。', + 'not_in' => '選択された:attributeは正しくありません。', + 'not_regex' => ':attributeの形式が正しくありません。', + 'numeric' => ':attributeには、数字を指定してください。', + 'password' => [ + 'letters' => ':attributeは、最低1文字以上の文字を含めてください。', + 'mixed' => ':attributeは、最低1文字以上の大文字と小文字をそれぞれ含めてください。', + 'numbers' => ':attributeは、最低1文字以上の数字を含めてください。', + 'symbols' => ':attributeは、最低1文字以上の記号を含めてください。', + 'uncompromised' => '指定の:attributeは、漏洩している恐れがあります。他の:attributeを指定してください。', ], - 'not_in' => '選択された:attributeは正しくありません。', - 'not_regex' => ':attributeの形式が正しくありません。', - 'numeric' => ':attributeには、数字を指定してください。', - 'password' => '正しいパスワードを指定してください。', - 'present' => ':attributeが存在していません。', - 'regex' => ':attributeに正しい形式を指定してください。', - 'required' => ':attributeは必ず指定してください。', - 'required_if' => ':otherが:valueの場合、:attributeも指定してください。', - 'required_unless' => ':otherが:valuesでない場合、:attributeを指定してください。', - 'required_with' => ':valuesを指定する場合は、:attributeも指定してください。', - 'required_with_all' => ':valuesを指定する場合は、:attributeも指定してください。', - 'required_without' => ':valuesを指定しない場合は、:attributeを指定してください。', + 'present' => ':attributeが存在していません。', + 'present_if' => ':attributeの値は:otherが:valueの際に必須です。', + 'present_unless' => ':attributeは、:otherが:valueでない限り、存在している必要があります。', + 'present_with' => ':attributeは、:valuesが存在するときに存在している必要があります。', + 'present_with_all' => ':attributeは:valuesがある場合に必須です。', + 'prohibited' => ':attributeは入力禁止です。', + 'prohibited_if' => ':otherが:valueの場合、:attributeは入力禁止です。', + 'prohibited_unless' => ':otherが:valueでない場合、:attributeは入力禁止です。', + 'prohibits' => 'attributeは:otherの入力を禁じています。', + 'regex' => ':attributeに正しい形式を指定してください。', + 'required' => ':attributeは必ず指定してください。', + 'required_array_keys' => ':attributeは、:valuesの項目を含めてください。', + 'required_if' => ':otherが:valueの場合、:attributeも指定してください。', + 'required_if_accepted' => ':attributeは、:otherが承認された場合は、必ず指定してください。', + 'required_if_declined' => ':attributeは、:otherが拒否された場合は、必ず指定してください。', + 'required_unless' => ':otherが:valuesでない場合、:attributeを指定してください。', + 'required_with' => ':valuesを指定する場合は、:attributeも指定してください。', + 'required_with_all' => ':valuesを指定する場合は、:attributeも指定してください。', + 'required_without' => ':valuesを指定しない場合は、:attributeを指定してください。', 'required_without_all' => ':valuesのどれも指定しない場合は、:attributeを指定してください。', - 'same' => ':attributeと:otherには同じ値を指定してください。', - 'size' => [ + 'same' => ':attributeと:otherには同じ値を指定してください。', + 'size' => [ 'numeric' => ':attributeは:sizeを指定してください。', - 'file' => ':attributeのファイルは、:sizeキロバイトでなくてはなりません。', - 'string' => ':attributeは:size文字で指定してください。', - 'array' => ':attributeは:size個指定してください。', + 'file' => ':attributeのファイルは、:size kbでなくてはなりません。', + 'string' => ':attributeは:size文字で指定してください。', + 'array' => ':attributeは:size個指定してください。', ], - 'starts_with' => ':attributeには、:valuesのどれかで始まる値を指定してください。', - 'string' => ':attributeは文字列を指定してください。', - 'timezone' => ':attributeには、有効なゾーンを指定してください。', - 'unique' => ':attributeの値は既に存在しています。', - 'uploaded' => ':attributeのアップロードに失敗しました。', - 'url' => ':attributeに正しい形式を指定してください。', - 'uuid' => ':attributeに有効なUUIDを指定してください。', + 'starts_with' => ':attributeには、:valuesのどれかで始まる値を指定してください。', + 'string' => ':attributeは文字列を指定してください。', + 'timezone' => ':attributeには、有効なゾーンを指定してください。', + 'unique' => ':attributeの値は既に存在しています。', + 'uploaded' => ':attributeのアップロードに失敗しました。', + 'uppercase' => ':attributeは、大文字のみで指定してください。', + 'url' => ':attributeに正しい形式を指定してください。', + 'ulid' => ':attributeに有効なULIDを指定してください。', + 'uuid' => ':attributeに有効なUUIDを指定してください。', /* |-------------------------------------------------------------------------- - | Custom バリデーション言語行 + | Custom Validation Language Lines |-------------------------------------------------------------------------- | - | "属性.ルール"の規約でキーを指定することでカスタムバリデーション - | メッセージを定義できます。指定した属性ルールに対する特定の - | カスタム言語行を手早く指定できます。 + | Here you may specify custom validation messages for attributes using the + | convention "attribute.rule" to name the lines. This makes it quick to + | specify a specific custom language line for a given attribute rule. | */ @@ -133,19 +166,95 @@ '属性名' => [ 'ルール名' => 'カスタムメッセージ', ], + 'terms' => [ + 'required' => '登録には規約への同意が必須となります。', + ], ], /* |-------------------------------------------------------------------------- - | カスタムバリデーション属性名 + | Custom Validation Attributes |-------------------------------------------------------------------------- | - | 以下の言語行は、例えば"email"の代わりに「メールアドレス」のように、 - | 読み手にフレンドリーな表現でプレースホルダーを置き換えるために指定する - | 言語行です。これはメッセージをよりきれいに表示するために役に立ちます。 + | The following language lines are used to swap our attribute placeholder + | with something more reader friendly such as "E-Mail Address" instead + | of "email". This simply helps us make our message more expressive. | */ - 'attributes' => [], + 'attributes' => [ + 'address' => '住所', + 'age' => '歳', + 'amount' => '額', + 'area' => 'エリア', + 'available' => '利用可能', + 'birthday' => '誕生日', + 'body' => '本文', + 'city' => '市', + 'content' => 'コンテンツ', + 'country' => '国', + 'created_at' => '作成日', + 'creator' => '作成者', + 'current_password' => '現在のパスワード', + 'date' => '日付', + 'date_of_birth' => '生年月日', + 'day' => '日', + 'deleted_at' => '削除日', + 'description' => '説明', + 'district' => '地区', + 'duration' => '期間', + 'email' => 'メールアドレス', + 'excerpt' => '抜粋', + 'filter' => 'フィルタ', + 'first_name' => '名', + 'gender' => '性別', + 'group' => 'グループ', + 'hour' => '時間', + 'image' => '画像', + 'last_name' => '姓', + 'lesson' => 'レッスン', + 'line_address_1' => '回線アドレス1', + 'line_address_2' => '回線アドレス2', + 'message' => 'メッセージ', + 'middle_name' => 'ミドルネーム', + 'minute' => '分', + 'mobile' => '携帯', + 'month' => '月', + 'name' => '名前', + 'national_code' => '国コード', + 'number' => '番号', + 'password' => 'パスワード', + 'password_confirmation' => '確認用パスワード', + 'phone' => '電話番号', + 'photo' => '写真', + 'postal_code' => '郵便番号', + 'prefecture' => '都道府県', + 'price' => '価格', + 'province' => '都道府県', + 'recaptcha_response_field' => 'recaptcha応答フィールド', + 'remember' => '記憶', + 'restored_at' => 'で復元', + 'result_text_under_image' => '画像の下の結果テキスト', + 'role' => '役割', + 'second' => '秒', + 'sex' => '性別', + 'short_text' => '短いテキスト', + 'size' => 'サイズ', + 'state' => '状態', + 'street' => '街', + 'student' => '学生', + 'subject' => '課題', + 'teacher' => '先生', + 'terms' => '利用規約', + 'test_description' => 'テスト内容', + 'test_locale' => 'テストロケール', + 'test_name' => 'テスト名', + 'text' => 'テキスト', + 'time' => '時間', + 'title' => 'タイトル', + 'updated_at' => '更新日', + 'username' => 'ユーザー名', + 'year' => '年', + ], ]; diff --git a/src/lang/en/validation.php b/src/lang/en/validation.php index c2a34e4..c3e94e1 100644 --- a/src/lang/en/validation.php +++ b/src/lang/en/validation.php @@ -1,68 +1,193 @@ 'The :attribute must be accepted.', - 'active_url' => 'The :attribute is not a valid URL.', - 'after' => 'The :attribute must be a date after :date.', - 'alpha' => 'The :attribute may only contain letters.', - 'alpha_dash' => 'The :attribute may only contain letters, numbers, and dashes.', - 'alpha_num' => 'The :attribute may only contain letters and numbers.', - 'array' => 'The :attribute must be an array.', - 'before' => 'The :attribute must be a date before :date.', + + /* + |-------------------------------------------------------------------------- + | Validation Language Lines + |-------------------------------------------------------------------------- + | + | The following language lines contain the default error messages used by + | the validator class. Some of these rules have multiple versions such + | as the size rules. Feel free to tweak each of these messages here. + | + */ + + 'accepted' => 'The :attribute field must be accepted.', + 'accepted_if' => 'The :attribute field must be accepted when :other is :value.', + 'active_url' => 'The :attribute field must be a valid URL.', + 'after' => 'The :attribute field must be a date after :date.', + 'after_or_equal' => 'The :attribute field must be a date after or equal to :date.', + 'alpha' => 'The :attribute field must only contain letters.', + 'alpha_dash' => 'The :attribute field must only contain letters, numbers, dashes, and underscores.', + 'alpha_num' => 'The :attribute field must only contain letters and numbers.', + 'array' => 'The :attribute field must be an array.', + 'ascii' => 'The :attribute field must only contain single-byte alphanumeric characters and symbols.', + 'before' => 'The :attribute field must be a date before :date.', + 'before_or_equal' => 'The :attribute field must be a date before or equal to :date.', 'between' => [ - 'numeric' => 'The :attribute must be between :min and :max.', - 'file' => 'The :attribute must be between :min and :max kilobytes.', - 'string' => 'The :attribute must be between :min and :max characters.', - 'array' => 'The :attribute must have between :min and :max items.', + 'array' => 'The :attribute field must have between :min and :max items.', + 'file' => 'The :attribute field must be between :min and :max kilobytes.', + 'numeric' => 'The :attribute field must be between :min and :max.', + 'string' => 'The :attribute field must be between :min and :max characters.', ], 'boolean' => 'The :attribute field must be true or false.', - 'confirmed' => 'The :attribute confirmation does not match.', - 'date' => 'The :attribute is not a valid date.', - 'date_format' => 'The :attribute does not match the format :format.', - 'different' => 'The :attribute and :other must be different.', - 'digits' => 'The :attribute must be :digits digits.', - 'digits_between' => 'The :attribute must be between :min and :max digits.', - 'email' => 'The :attribute must be a valid email address.', + 'can' => 'The :attribute field contains an unauthorized value.', + 'confirmed' => 'The :attribute field confirmation does not match.', + 'current_password' => 'The password is incorrect.', + 'date' => 'The :attribute field must be a valid date.', + 'date_equals' => 'The :attribute field must be a date equal to :date.', + 'date_format' => 'The :attribute field must match the format :format.', + 'decimal' => 'The :attribute field must have :decimal decimal places.', + 'declined' => 'The :attribute field must be declined.', + 'declined_if' => 'The :attribute field must be declined when :other is :value.', + 'different' => 'The :attribute field and :other must be different.', + 'digits' => 'The :attribute field must be :digits digits.', + 'digits_between' => 'The :attribute field must be between :min and :max digits.', + 'dimensions' => 'The :attribute field has invalid image dimensions.', + 'distinct' => 'The :attribute field has a duplicate value.', + 'doesnt_end_with' => 'The :attribute field must not end with one of the following: :values.', + 'doesnt_start_with' => 'The :attribute field must not start with one of the following: :values.', + 'email' => 'The :attribute field must be a valid email address.', + 'ends_with' => 'The :attribute field must end with one of the following: :values.', + 'enum' => 'The selected :attribute is invalid.', 'exists' => 'The selected :attribute is invalid.', - 'filled' => 'The :attribute field is required.', - 'image' => 'The :attribute must be an image.', + 'extensions' => 'The :attribute field must have one of the following extensions: :values.', + 'file' => 'The :attribute field must be a file.', + 'filled' => 'The :attribute field must have a value.', + 'gt' => [ + 'array' => 'The :attribute field must have more than :value items.', + 'file' => 'The :attribute field must be greater than :value kilobytes.', + 'numeric' => 'The :attribute field must be greater than :value.', + 'string' => 'The :attribute field must be greater than :value characters.', + ], + 'gte' => [ + 'array' => 'The :attribute field must have :value items or more.', + 'file' => 'The :attribute field must be greater than or equal to :value kilobytes.', + 'numeric' => 'The :attribute field must be greater than or equal to :value.', + 'string' => 'The :attribute field must be greater than or equal to :value characters.', + ], + 'hex_color' => 'The :attribute field must be a valid hexadecimal color.', + 'image' => 'The :attribute field must be an image.', 'in' => 'The selected :attribute is invalid.', - 'integer' => 'The :attribute must be an integer.', - 'ip' => 'The :attribute must be a valid IP address.', - 'json' => 'The :attribute must be a valid JSON string.', + 'in_array' => 'The :attribute field must exist in :other.', + 'integer' => 'The :attribute field must be an integer.', + 'ip' => 'The :attribute field must be a valid IP address.', + 'ipv4' => 'The :attribute field must be a valid IPv4 address.', + 'ipv6' => 'The :attribute field must be a valid IPv6 address.', + 'json' => 'The :attribute field must be a valid JSON string.', + 'list' => 'The :attribute field must be a list.', + 'lowercase' => 'The :attribute field must be lowercase.', + 'lt' => [ + 'array' => 'The :attribute field must have less than :value items.', + 'file' => 'The :attribute field must be less than :value kilobytes.', + 'numeric' => 'The :attribute field must be less than :value.', + 'string' => 'The :attribute field must be less than :value characters.', + ], + 'lte' => [ + 'array' => 'The :attribute field must not have more than :value items.', + 'file' => 'The :attribute field must be less than or equal to :value kilobytes.', + 'numeric' => 'The :attribute field must be less than or equal to :value.', + 'string' => 'The :attribute field must be less than or equal to :value characters.', + ], + 'mac_address' => 'The :attribute field must be a valid MAC address.', 'max' => [ - 'numeric' => 'The :attribute may not be greater than :max.', - 'file' => 'The :attribute may not be greater than :max kilobytes.', - 'string' => 'The :attribute may not be greater than :max characters.', - 'array' => 'The :attribute may not have more than :max items.', + 'array' => 'The :attribute field must not have more than :max items.', + 'file' => 'The :attribute field must not be greater than :max kilobytes.', + 'numeric' => 'The :attribute field must not be greater than :max.', + 'string' => 'The :attribute field must not be greater than :max characters.', ], - 'mimes' => 'The :attribute must be a file of type: :values.', + 'max_digits' => 'The :attribute field must not have more than :max digits.', + 'mimes' => 'The :attribute field must be a file of type: :values.', + 'mimetypes' => 'The :attribute field must be a file of type: :values.', 'min' => [ - 'numeric' => 'The :attribute must be at least :min.', - 'file' => 'The :attribute must be at least :min kilobytes.', - 'string' => 'The :attribute must be at least :min characters.', - 'array' => 'The :attribute must have at least :min items.', + 'array' => 'The :attribute field must have at least :min items.', + 'file' => 'The :attribute field must be at least :min kilobytes.', + 'numeric' => 'The :attribute field must be at least :min.', + 'string' => 'The :attribute field must be at least :min characters.', ], + 'min_digits' => 'The :attribute field must have at least :min digits.', + 'missing' => 'The :attribute field must be missing.', + 'missing_if' => 'The :attribute field must be missing when :other is :value.', + 'missing_unless' => 'The :attribute field must be missing unless :other is :value.', + 'missing_with' => 'The :attribute field must be missing when :values is present.', + 'missing_with_all' => 'The :attribute field must be missing when :values are present.', + 'multiple_of' => 'The :attribute field must be a multiple of :value.', 'not_in' => 'The selected :attribute is invalid.', - 'numeric' => 'The :attribute must be a number.', + 'not_regex' => 'The :attribute field format is invalid.', + 'numeric' => 'The :attribute field must be a number.', + 'password' => [ + 'letters' => 'The :attribute field must contain at least one letter.', + 'mixed' => 'The :attribute field must contain at least one uppercase and one lowercase letter.', + 'numbers' => 'The :attribute field must contain at least one number.', + 'symbols' => 'The :attribute field must contain at least one symbol.', + 'uncompromised' => 'The given :attribute has appeared in a data leak. Please choose a different :attribute.', + ], 'present' => 'The :attribute field must be present.', - 'regex' => 'The :attribute format is invalid.', + 'present_if' => 'The :attribute field must be present when :other is :value.', + 'present_unless' => 'The :attribute field must be present unless :other is :value.', + 'present_with' => 'The :attribute field must be present when :values is present.', + 'present_with_all' => 'The :attribute field must be present when :values are present.', + 'prohibited' => 'The :attribute field is prohibited.', + 'prohibited_if' => 'The :attribute field is prohibited when :other is :value.', + 'prohibited_unless' => 'The :attribute field is prohibited unless :other is in :values.', + 'prohibits' => 'The :attribute field prohibits :other from being present.', + 'regex' => 'The :attribute field format is invalid.', 'required' => 'The :attribute field is required.', + 'required_array_keys' => 'The :attribute field must contain entries for: :values.', 'required_if' => 'The :attribute field is required when :other is :value.', + 'required_if_accepted' => 'The :attribute field is required when :other is accepted.', + 'required_if_declined' => 'The :attribute field is required when :other is declined.', 'required_unless' => 'The :attribute field is required unless :other is in :values.', 'required_with' => 'The :attribute field is required when :values is present.', - 'required_with_all' => 'The :attribute field is required when :values is present.', + 'required_with_all' => 'The :attribute field is required when :values are present.', 'required_without' => 'The :attribute field is required when :values is not present.', 'required_without_all' => 'The :attribute field is required when none of :values are present.', - 'same' => 'The :attribute and :other must match.', + 'same' => 'The :attribute field must match :other.', 'size' => [ - 'numeric' => 'The :attribute must be :size.', - 'file' => 'The :attribute must be :size kilobytes.', - 'string' => 'The :attribute must be :size characters.', - 'array' => 'The :attribute must contain :size items.', + 'array' => 'The :attribute field must contain :size items.', + 'file' => 'The :attribute field must be :size kilobytes.', + 'numeric' => 'The :attribute field must be :size.', + 'string' => 'The :attribute field must be :size characters.', ], - 'string' => 'The :attribute must be a string.', - 'timezone' => 'The :attribute must be a valid zone.', + 'starts_with' => 'The :attribute field must start with one of the following: :values.', + 'string' => 'The :attribute field must be a string.', + 'timezone' => 'The :attribute field must be a valid timezone.', 'unique' => 'The :attribute has already been taken.', - 'url' => 'The :attribute format is invalid.' + 'uploaded' => 'The :attribute failed to upload.', + 'uppercase' => 'The :attribute field must be uppercase.', + 'url' => 'The :attribute field must be a valid URL.', + 'ulid' => 'The :attribute field must be a valid ULID.', + 'uuid' => 'The :attribute field must be a valid UUID.', + + /* + |-------------------------------------------------------------------------- + | Custom Validation Language Lines + |-------------------------------------------------------------------------- + | + | Here you may specify custom validation messages for attributes using the + | convention "attribute.rule" to name the lines. This makes it quick to + | specify a specific custom language line for a given attribute rule. + | + */ + + 'custom' => [ + 'attribute-name' => [ + 'rule-name' => 'custom-message', + ], + ], + + /* + |-------------------------------------------------------------------------- + | Custom Validation Attributes + |-------------------------------------------------------------------------- + | + | The following language lines are used to swap our attribute placeholder + | with something more reader friendly such as "E-Mail Address" instead + | of "email". This simply helps us make our message more expressive. + | + */ + + 'attributes' => [], + ]; diff --git a/src/lang/ja/validation.php b/src/lang/ja/validation.php index 12407a4..aeb945b 100644 --- a/src/lang/ja/validation.php +++ b/src/lang/ja/validation.php @@ -2,130 +2,163 @@ return [ - /* - |-------------------------------------------------------------------------- - | バリデーション言語行 - |-------------------------------------------------------------------------- - | - | 以下の言語行はバリデタークラスにより使用されるデフォルトのエラー - | メッセージです。サイズルールのようにいくつかのバリデーションを - | 持っているものもあります。メッセージはご自由に調整してください。 - | - */ + /* メッセージの内容がご自身のアプリに適さない場合には、必要に応じて修正願います */ - 'accepted' => ':attributeを承認してください。', - 'active_url' => ':attributeが有効なURLではありません。', - 'after' => ':attributeには、:dateより後の日付を指定してください。', - 'after_or_equal' => ':attributeには、:date以降の日付を指定してください。', - 'alpha' => ':attributeはアルファベットのみがご利用できます。', - 'alpha_dash' => ':attributeはアルファベットとダッシュ(-)及び下線(_)がご利用できます。', - 'alpha_num' => ':attributeはアルファベット数字がご利用できます。', - 'array' => ':attributeは配列でなくてはなりません。', - 'before' => ':attributeには、:dateより前の日付をご利用ください。', - 'before_or_equal' => ':attributeには、:date以前の日付をご利用ください。', - 'between' => [ + 'accepted' => ':attributeを承認してください。', + 'accepted_if' => ':otherが:valueの場合、:attributeを承認してください。', + 'active_url' => ':attributeが有効なURLではありません。', + 'after' => ':attributeには、:dateより後の日付を指定してください。', + 'after_or_equal' => ':attributeには、:date以降の日付を指定してください。', + 'alpha' => ':attributeはアルファベットのみがご利用できます。', + 'alpha_dash' => ':attributeはアルファベットとダッシュ(-)及び下線(_)がご利用できます。', + 'alpha_num' => ':attributeはアルファベット数字がご利用できます。', + 'array' => ':attributeは配列でなくてはなりません。', + 'ascii' => ':attributeは半角の英数字や記号のみで指定してください。', + 'before' => ':attributeには、:dateより前の日付をご利用ください。', + 'before_or_equal' => ':attributeには、:date以前の日付をご利用ください。', + 'between' => [ 'numeric' => ':attributeは、:minから:maxの間で指定してください。', - 'file' => ':attributeは、:min kBから、:max kBの間で指定してください。', - 'string' => ':attributeは、:min文字から、:max文字の間で指定してください。', - 'array' => ':attributeは、:min個から:max個の間で指定してください。', + 'file' => ':attributeは、:min kbから、:max kbの間で指定してください。', + 'string' => ':attributeは、:min文字から、:max文字の間で指定してください。', + 'array' => ':attributeは、:min個から:max個の間で指定してください。', ], - 'boolean' => ':attributeは、trueかfalseを指定してください。', - 'confirmed' => ':attributeと、確認フィールドとが、一致していません。', - 'date' => ':attributeには有効な日付を指定してください。', - 'date_equals' => ':attributeには、:dateと同じ日付けを指定してください。', - 'date_format' => ':attributeは:format形式で指定してください。', - 'different' => ':attributeと:otherには、異なった内容を指定してください。', - 'digits' => ':attributeは:digits桁で指定してください。', - 'digits_between' => ':attributeは:min桁から:max桁の間で指定してください。', - 'dimensions' => ':attributeの図形サイズが正しくありません。', - 'distinct' => ':attributeには異なった値を指定してください。', - 'email' => ':attributeには、有効なメールアドレスを指定してください。', - 'ends_with' => ':attributeには、:valuesのどれかで終わる値を指定してください。', - 'exists' => '選択された:attributeは正しくありません。', - 'file' => ':attributeにはファイルを指定してください。', - 'filled' => ':attributeに値を指定してください。', - 'gt' => [ + 'boolean' => ':attributeは、trueかfalseを指定してください。', + 'can' => ':attributeに権限のない値が含まれています。', + 'confirmed' => ':attributeと確認フィールドが一致していません。', + 'current_password' => 'パスワードが正しくありません。', + 'date' => ':attributeには有効な日付を指定してください。', + 'date_equals' => ':attributeには、:dateと同じ日付けを指定してください。', + 'date_format' => ':attributeは:format形式で指定してください。', + 'decimal' => ':attributeは、小数点以下:decimal桁の数字を指定してください。', + 'declined' => ':attributeは、拒否する指定をしてください。', + 'declined_if' => ':attributeは、:otherが:valueの時は、拒否する指定をしてください。', + 'different' => ':attributeと:otherには、異なった内容を指定してください。', + 'digits' => ':attributeは:digits桁で指定してください。', + 'digits_between' => ':attributeは:min桁から:max桁の間で指定してください。', + 'dimensions' => ':attributeの図形サイズが正しくありません。', + 'distinct' => ':attributeには異なった値を指定してください。', + 'doesnt_end_with' => ':attributeは、:values以外の値で終わるように指定してください。', + 'doesnt_start_with' => ':attributeは、:values以外の値で始まるように指定してください。', + 'email' => ':attributeには、有効なメールアドレスを指定してください。', + 'ends_with' => ':attributeには、:valuesのどれかで終わる値を指定してください。', + 'enum' => '選択された:attributeは正しくありません。', + 'exists' => '選択された:attributeは正しくありません。', + 'extensions' => ':attributeは、:valuesの拡張子を指定してください。', + 'file' => ':attributeにはファイルを指定してください。', + 'filled' => ':attributeに値を指定してください。', + 'gt' => [ 'numeric' => ':attributeには、:valueより大きな値を指定してください。', - 'file' => ':attributeには、:value kBより大きなファイルを指定してください。', - 'string' => ':attributeは、:value文字より長く指定してください。', - 'array' => ':attributeには、:value個より多くのアイテムを指定してください。', + 'file' => ':attributeには、:value kbより大きなファイルを指定してください。', + 'string' => ':attributeは、:value文字より長く指定してください。', + 'array' => ':attributeには、:value個より多くのアイテムを指定してください。', ], - 'gte' => [ + 'gte' => [ 'numeric' => ':attributeには、:value以上の値を指定してください。', - 'file' => ':attributeには、:value kB以上のファイルを指定してください。', - 'string' => ':attributeは、:value文字以上で指定してください。', - 'array' => ':attributeには、:value個以上のアイテムを指定してください。', + 'file' => ':attributeには、:value kb以上のファイルを指定してください。', + 'string' => ':attributeは、:value文字以上で指定してください。', + 'array' => ':attributeには、:value個以上のアイテムを指定してください。', ], - 'image' => ':attributeには画像ファイルを指定してください。', - 'in' => '選択された:attributeは正しくありません。', - 'in_array' => ':attributeには:otherの値を指定してください。', - 'integer' => ':attributeは整数で指定してください。', - 'ip' => ':attributeには、有効なIPアドレスを指定してください。', - 'ipv4' => ':attributeには、有効なIPv4アドレスを指定してください。', - 'ipv6' => ':attributeには、有効なIPv6アドレスを指定してください。', - 'json' => ':attributeには、有効なJSON文字列を指定してください。', - 'lt' => [ + 'hex_color' => ':attributeには、有効な16進数の色を指定してください。', + 'image' => ':attributeには画像ファイルを指定してください。', + 'in' => '選択された:attributeは正しくありません。', + 'in_array' => ':attributeには:otherの値を指定してください。', + 'integer' => ':attributeは整数で指定してください。', + 'ip' => ':attributeには、有効なIPアドレスを指定してください。', + 'ipv4' => ':attributeには、有効なIPv4アドレスを指定してください。', + 'ipv6' => ':attributeには、有効なIPv6アドレスを指定してください。', + 'json' => ':attributeには、有効なJSON文字列を指定してください。', + 'list' => ':attributeには、一覧を指定してください。', + 'lowercase' => ':attributeは、小文字のみで指定してください。', + 'lt' => [ 'numeric' => ':attributeには、:valueより小さな値を指定してください。', - 'file' => ':attributeには、:value kBより小さなファイルを指定してください。', - 'string' => ':attributeは、:value文字より短く指定してください。', - 'array' => ':attributeには、:value個より少ないアイテムを指定してください。', + 'file' => ':attributeには、:value kbより小さなファイルを指定してください。', + 'string' => ':attributeは、:value文字より短く指定してください。', + 'array' => ':attributeには、:value個より少ないアイテムを指定してください。', ], - 'lte' => [ + 'lte' => [ 'numeric' => ':attributeには、:value以下の値を指定してください。', - 'file' => ':attributeには、:value kB以下のファイルを指定してください。', - 'string' => ':attributeは、:value文字以下で指定してください。', - 'array' => ':attributeには、:value個以下のアイテムを指定してください。', + 'file' => ':attributeには、:value kb以下のファイルを指定してください。', + 'string' => ':attributeは、:value文字以下で指定してください。', + 'array' => ':attributeには、:value個以下のアイテムを指定してください。', ], - 'max' => [ + 'mac_address' => ':attributeには、有効なMACアドレスを指定してください。', + 'max' => [ 'numeric' => ':attributeには、:max以下の数字を指定してください。', - 'file' => ':attributeには、:max kB以下のファイルを指定してください。', - 'string' => ':attributeは、:max文字以下で指定してください。', - 'array' => ':attributeは:max個以下指定してください。', + 'file' => ':attributeには、:max kb以下のファイルを指定してください。', + 'string' => ':attributeは、:max文字以下で指定してください。', + 'array' => ':attributeは:max個以下指定してください。', ], - 'mimes' => ':attributeには:valuesタイプのファイルを指定してください。', - 'mimetypes' => ':attributeには:valuesタイプのファイルを指定してください。', - 'min' => [ + 'max_digits' => ':attributeは、:max桁以下で指定してください。', + 'mimes' => ':attributeには:valuesタイプのファイルを指定してください。', + 'mimetypes' => ':attributeには:valuesタイプのファイルを指定してください。', + 'min' => [ 'numeric' => ':attributeには、:min以上の数字を指定してください。', - 'file' => ':attributeには、:min kB以上のファイルを指定してください。', - 'string' => ':attributeは、:min文字以上で指定してください。', - 'array' => ':attributeは:min個以上指定してください。', + 'file' => ':attributeには、:min kb以上のファイルを指定してください。', + 'string' => ':attributeは、:min文字以上で指定してください。', + 'array' => ':attributeは:min個以上指定してください。', + ], + 'min_digits' => ':attributeは、:min桁以上で指定してください。', + 'missing' => ':attributeは存在してはいけません。', + 'missing_if' => ':otherが:valueの場合、:attributeは存在してはいけません。', + 'missing_unless' => ':otherが:valueでない場合、:attributeは存在してはいけません。', + 'missing_with' => ':valuesを指定する場合は、:attributeは存在してはいけません。 ', + 'missing_with_all' => ':valuesを指定する場合は、:attributeは存在してはいけません。 ', + 'multiple_of' => ':attributeには、:valueの倍数を指定してください。', + 'not_in' => '選択された:attributeは正しくありません。', + 'not_regex' => ':attributeの形式が正しくありません。', + 'numeric' => ':attributeには、数字を指定してください。', + 'password' => [ + 'letters' => ':attributeは、最低1文字以上の文字を含めてください。', + 'mixed' => ':attributeは、最低1文字以上の大文字と小文字をそれぞれ含めてください。', + 'numbers' => ':attributeは、最低1文字以上の数字を含めてください。', + 'symbols' => ':attributeは、最低1文字以上の記号を含めてください。', + 'uncompromised' => '指定の:attributeは、漏洩している恐れがあります。他の:attributeを指定してください。', ], - 'not_in' => '選択された:attributeは正しくありません。', - 'not_regex' => ':attributeの形式が正しくありません。', - 'numeric' => ':attributeには、数字を指定してください。', - 'password' => '正しいパスワードを指定してください。', - 'present' => ':attributeが存在していません。', - 'regex' => ':attributeに正しい形式を指定してください。', - 'required' => ':attributeは必ず指定してください。', - 'required_if' => ':otherが:valueの場合、:attributeも指定してください。', - 'required_unless' => ':otherが:valuesでない場合、:attributeを指定してください。', - 'required_with' => ':valuesを指定する場合は、:attributeも指定してください。', - 'required_with_all' => ':valuesを指定する場合は、:attributeも指定してください。', - 'required_without' => ':valuesを指定しない場合は、:attributeを指定してください。', + 'present' => ':attributeが存在していません。', + 'present_if' => ':attributeの値は:otherが:valueの際に必須です。', + 'present_unless' => ':attributeは、:otherが:valueでない限り、存在している必要があります。', + 'present_with' => ':attributeは、:valuesが存在するときに存在している必要があります。', + 'present_with_all' => ':attributeは:valuesがある場合に必須です。', + 'prohibited' => ':attributeは入力禁止です。', + 'prohibited_if' => ':otherが:valueの場合、:attributeは入力禁止です。', + 'prohibited_unless' => ':otherが:valueでない場合、:attributeは入力禁止です。', + 'prohibits' => 'attributeは:otherの入力を禁じています。', + 'regex' => ':attributeに正しい形式を指定してください。', + 'required' => ':attributeは必ず指定してください。', + 'required_array_keys' => ':attributeは、:valuesの項目を含めてください。', + 'required_if' => ':otherが:valueの場合、:attributeも指定してください。', + 'required_if_accepted' => ':attributeは、:otherが承認された場合は、必ず指定してください。', + 'required_if_declined' => ':attributeは、:otherが拒否された場合は、必ず指定してください。', + 'required_unless' => ':otherが:valuesでない場合、:attributeを指定してください。', + 'required_with' => ':valuesを指定する場合は、:attributeも指定してください。', + 'required_with_all' => ':valuesを指定する場合は、:attributeも指定してください。', + 'required_without' => ':valuesを指定しない場合は、:attributeを指定してください。', 'required_without_all' => ':valuesのどれも指定しない場合は、:attributeを指定してください。', - 'same' => ':attributeと:otherには同じ値を指定してください。', - 'size' => [ + 'same' => ':attributeと:otherには同じ値を指定してください。', + 'size' => [ 'numeric' => ':attributeは:sizeを指定してください。', - 'file' => ':attributeのファイルは、:sizeキロバイトでなくてはなりません。', - 'string' => ':attributeは:size文字で指定してください。', - 'array' => ':attributeは:size個指定してください。', + 'file' => ':attributeのファイルは、:size kbでなくてはなりません。', + 'string' => ':attributeは:size文字で指定してください。', + 'array' => ':attributeは:size個指定してください。', ], - 'starts_with' => ':attributeには、:valuesのどれかで始まる値を指定してください。', - 'string' => ':attributeは文字列を指定してください。', - 'timezone' => ':attributeには、有効なゾーンを指定してください。', - 'unique' => ':attributeの値は既に存在しています。', - 'uploaded' => ':attributeのアップロードに失敗しました。', - 'url' => ':attributeに正しい形式を指定してください。', - 'uuid' => ':attributeに有効なUUIDを指定してください。', + 'starts_with' => ':attributeには、:valuesのどれかで始まる値を指定してください。', + 'string' => ':attributeは文字列を指定してください。', + 'timezone' => ':attributeには、有効なゾーンを指定してください。', + 'unique' => ':attributeの値は既に存在しています。', + 'uploaded' => ':attributeのアップロードに失敗しました。', + 'uppercase' => ':attributeは、大文字のみで指定してください。', + 'url' => ':attributeに正しい形式を指定してください。', + 'ulid' => ':attributeに有効なULIDを指定してください。', + 'uuid' => ':attributeに有効なUUIDを指定してください。', /* |-------------------------------------------------------------------------- - | Custom バリデーション言語行 + | Custom Validation Language Lines |-------------------------------------------------------------------------- | - | "属性.ルール"の規約でキーを指定することでカスタムバリデーション - | メッセージを定義できます。指定した属性ルールに対する特定の - | カスタム言語行を手早く指定できます。 + | Here you may specify custom validation messages for attributes using the + | convention "attribute.rule" to name the lines. This makes it quick to + | specify a specific custom language line for a given attribute rule. | */ @@ -133,19 +166,95 @@ '属性名' => [ 'ルール名' => 'カスタムメッセージ', ], + 'terms' => [ + 'required' => '登録には規約への同意が必須となります。', + ], ], /* |-------------------------------------------------------------------------- - | カスタムバリデーション属性名 + | Custom Validation Attributes |-------------------------------------------------------------------------- | - | 以下の言語行は、例えば"email"の代わりに「メールアドレス」のように、 - | 読み手にフレンドリーな表現でプレースホルダーを置き換えるために指定する - | 言語行です。これはメッセージをよりきれいに表示するために役に立ちます。 + | The following language lines are used to swap our attribute placeholder + | with something more reader friendly such as "E-Mail Address" instead + | of "email". This simply helps us make our message more expressive. | */ - 'attributes' => [], + 'attributes' => [ + 'address' => '住所', + 'age' => '歳', + 'amount' => '額', + 'area' => 'エリア', + 'available' => '利用可能', + 'birthday' => '誕生日', + 'body' => '本文', + 'city' => '市', + 'content' => 'コンテンツ', + 'country' => '国', + 'created_at' => '作成日', + 'creator' => '作成者', + 'current_password' => '現在のパスワード', + 'date' => '日付', + 'date_of_birth' => '生年月日', + 'day' => '日', + 'deleted_at' => '削除日', + 'description' => '説明', + 'district' => '地区', + 'duration' => '期間', + 'email' => 'メールアドレス', + 'excerpt' => '抜粋', + 'filter' => 'フィルタ', + 'first_name' => '名', + 'gender' => '性別', + 'group' => 'グループ', + 'hour' => '時間', + 'image' => '画像', + 'last_name' => '姓', + 'lesson' => 'レッスン', + 'line_address_1' => '回線アドレス1', + 'line_address_2' => '回線アドレス2', + 'message' => 'メッセージ', + 'middle_name' => 'ミドルネーム', + 'minute' => '分', + 'mobile' => '携帯', + 'month' => '月', + 'name' => '名前', + 'national_code' => '国コード', + 'number' => '番号', + 'password' => 'パスワード', + 'password_confirmation' => '確認用パスワード', + 'phone' => '電話番号', + 'photo' => '写真', + 'postal_code' => '郵便番号', + 'prefecture' => '都道府県', + 'price' => '価格', + 'province' => '都道府県', + 'recaptcha_response_field' => 'recaptcha応答フィールド', + 'remember' => '記憶', + 'restored_at' => 'で復元', + 'result_text_under_image' => '画像の下の結果テキスト', + 'role' => '役割', + 'second' => '秒', + 'sex' => '性別', + 'short_text' => '短いテキスト', + 'size' => 'サイズ', + 'state' => '状態', + 'street' => '街', + 'student' => '学生', + 'subject' => '課題', + 'teacher' => '先生', + 'terms' => '利用規約', + 'test_description' => 'テスト内容', + 'test_locale' => 'テストロケール', + 'test_name' => 'テスト名', + 'text' => 'テキスト', + 'time' => '時間', + 'title' => 'タイトル', + 'updated_at' => '更新日', + 'username' => 'ユーザー名', + 'year' => '年', + ], ]; diff --git a/tests/Rules/FileWrapperTest.php b/tests/Rules/FileWrapperTest.php index c71573f..dc3856d 100644 --- a/tests/Rules/FileWrapperTest.php +++ b/tests/Rules/FileWrapperTest.php @@ -40,8 +40,8 @@ public static function provide_file_rules_can_work_correctly(): array 'fails' => true, 'messages' => [ 'photo' => [ - 'The photo must be at least 40 kilobytes.', - 'validation.dimensions', + 'The photo field must be at least 40 kilobytes.', + 'The photo field has invalid image dimensions.', ], ], ], @@ -62,8 +62,8 @@ public static function provide_file_rules_can_work_correctly(): array 'fails' => true, 'messages' => [ 'photo' => [ - 'The photo must be a file of type: png, gif.', - 'The photo may not be greater than 30 kilobytes.', + 'The photo field must be a file of type: png, gif.', + 'The photo field must not be greater than 30 kilobytes.', ], ], ], @@ -85,8 +85,8 @@ public static function provide_file_rules_can_work_correctly(): array 'fails' => true, 'messages' => [ 'photo' => [ - 'The photo must be between 20 and 30 kilobytes.', - 'The photo must be an image.', + 'The photo field must be between 20 and 30 kilobytes.', + 'The photo field must be an image.', ], ], ], diff --git a/tests/Rules/PasswordWrapperTest.php b/tests/Rules/PasswordWrapperTest.php index 56eb27b..8babc91 100644 --- a/tests/Rules/PasswordWrapperTest.php +++ b/tests/Rules/PasswordWrapperTest.php @@ -29,7 +29,7 @@ public static function provide_password_rule_can_work_correctly(): array 'expected' => [ 'fails' => true, 'messages' => [ - 'password' => ['The password must be at least 8 characters.'], + 'password' => ['The password field must be at least 8 characters.'], ], ], ], @@ -60,7 +60,7 @@ public static function provide_password_rule_can_work_correctly(): array 'expected' => [ 'fails' => true, 'messages' => [ - 'password' => ['The password may not be greater than 16 characters.'], + 'password' => ['The password field must not be greater than 16 characters.'], ], ], ], @@ -85,9 +85,9 @@ public static function provide_password_rule_can_work_correctly(): array 'fails' => true, 'messages' => [ 'password' => [ - 'validation.password.mixed', - 'validation.password.symbols', - 'validation.password.numbers', + 'The password field must contain at least one uppercase and one lowercase letter.', + 'The password field must contain at least one symbol.', + 'The password field must contain at least one number.', ], ], ], diff --git a/tests/ValidatorFactoryTest.php b/tests/ValidatorFactoryTest.php index f6870d0..601358c 100644 --- a/tests/ValidatorFactoryTest.php +++ b/tests/ValidatorFactoryTest.php @@ -73,7 +73,7 @@ public static function provide_make_can_make_validator_correctly(): array 'expected' => [ 'fails' => true, 'errors' => [ - 'id' => ['The id must be an integer.'], + 'id' => ['The id field must be an integer.'], 'name' => ['The name field is required.'], 'email' => ['The email field is required.'], ], @@ -94,9 +94,9 @@ public static function provide_make_can_make_validator_correctly(): array 'expected' => [ 'fails' => true, 'errors' => [ - 'id' => ['The id must be at least 1.'], - 'name' => ['The name must be at least 3 characters.'], - 'email' => ['The email must be a valid email address.'], + 'id' => ['The id field must be at least 1.'], + 'name' => ['The name field must be at least 3 characters.'], + 'email' => ['The email field must be a valid email address.'], ], ], ], @@ -115,7 +115,7 @@ public static function provide_make_can_make_validator_correctly(): array 'expected' => [ 'fails' => true, 'errors' => [ - 'name' => ['The name may not be greater than 10 characters.'], + 'name' => ['The name field must not be greater than 10 characters.'], ], ], ], @@ -152,8 +152,8 @@ public static function provide_make_can_make_validator_correctly(): array 'fails' => true, 'errors' => [ 'id' => ['idは整数で指定してください。'], - 'name' => ['nameは必ず指定してください。'], - 'email' => ['emailは必ず指定してください。'], + 'name' => ['名前は必ず指定してください。'], + 'email' => ['メールアドレスは必ず指定してください。'], ], ], ], @@ -173,8 +173,8 @@ public static function provide_make_can_make_validator_correctly(): array 'fails' => true, 'errors' => [ 'id' => ['idには、1以上の数字を指定してください。'], - 'name' => ['nameは、3文字以上で指定してください。'], - 'email' => ['emailには、有効なメールアドレスを指定してください。'], + 'name' => ['名前は、3文字以上で指定してください。'], + 'email' => ['メールアドレスには、有効なメールアドレスを指定してください。'], ], ], ], @@ -193,7 +193,7 @@ public static function provide_make_can_make_validator_correctly(): array 'expected' => [ 'fails' => true, 'errors' => [ - 'name' => ['nameは、10文字以下で指定してください。'], + 'name' => ['名前は、10文字以下で指定してください。'], ], ], ],