diff --git a/lang/de/validation.php b/lang/de/validation.php new file mode 100644 index 0000000..59964be --- /dev/null +++ b/lang/de/validation.php @@ -0,0 +1,192 @@ + ':attribute muss akzeptiert werden.', + 'accepted_if' => ':attribute muss akzeptiert werden, wenn :other :value ist.', + 'active_url' => ':attribute ist keine gültige URL.', + 'after' => ':attribute muss ein Datum nach :date sein.', + 'after_or_equal' => ':attribute muss ein Datum nach oder gleich :date sein.', + 'alpha' => ':attribute darf nur Buchstaben enthalten.', + 'alpha_dash' => ':attribute darf nur Buchstaben, Zahlen, Binde- und Unterstriche enthalten.', + 'alpha_num' => ':attribute darf nur Buchstaben und Zahlen enthalten.', + 'any_of' => ':attribute ist ungültig.', + 'array' => ':attribute muss ein Array sein.', + 'ascii' => ':attribute darf nur alphanumerische Einzelbyte-Zeichen und Symbole enthalten.', + 'before' => ':attribute muss ein Datum vor :date sein.', + 'before_or_equal' => ':attribute muss ein Datum vor oder gleich :date sein.', + 'between' => [ + 'array' => ':attribute muss zwischen :min und :max Elemente haben.', + 'file' => ':attribute muss zwischen :min und :max Kilobytes groß sein.', + 'numeric' => ':attribute muss zwischen :min und :max liegen.', + 'string' => ':attribute muss zwischen :min und :max Zeichen lang sein.', + ], + 'boolean' => ':attribute muss wahr oder falsch sein.', + 'can' => ':attribute enthält einen nicht autorisierten Wert.', + 'confirmed' => ':attribute stimmt nicht mit der Bestätigung überein.', + 'contains' => ':attribute fehlt ein erforderlicher Wert.', + 'current_password' => 'Das Passwort ist falsch.', + 'date' => ':attribute muss ein gültiges Datum sein.', + 'date_equals' => ':attribute muss ein Datum gleich :date sein.', + 'date_format' => ':attribute muss dem Format :format entsprechen.', + 'decimal' => ':attribute muss :decimal Dezimalstellen haben.', + 'declined' => ':attribute muss abgelehnt werden.', + 'declined_if' => ':attribute muss abgelehnt werden, wenn :other :value ist.', + 'different' => ':attribute und :other müssen sich unterscheiden.', + 'digits' => ':attribute muss :digits Ziffern lang sein.', + 'digits_between' => ':attribute muss zwischen :min und :max Ziffern lang sein.', + 'dimensions' => ':attribute hat ungültige Bildabmessungen.', + 'distinct' => ':attribute hat einen doppelten Wert.', + 'doesnt_contain' => ':attribute darf keinen der folgenden Werte enthalten: :values.', + 'doesnt_end_with' => ':attribute darf nicht mit einem der folgenden Werte enden: :values.', + 'doesnt_start_with' => ':attribute darf nicht mit einem der folgenden Werte beginnen: :values.', + 'email' => ':attribute muss eine gültige E-Mail-Adresse sein.', + 'encoding' => ':attribute muss in :encoding kodiert sein.', + 'ends_with' => ':attribute muss mit einem der folgenden Werte enden: :values.', + 'enum' => 'Der gewählte Wert für :attribute ist ungültig.', + 'exists' => 'Der gewählte Wert für :attribute ist ungültig.', + 'extensions' => ':attribute muss eine der folgenden Dateiendungen haben: :values.', + 'file' => ':attribute muss eine Datei sein.', + 'filled' => ':attribute muss ausgefüllt sein.', + 'gt' => [ + 'array' => ':attribute muss mehr als :value Elemente haben.', + 'file' => ':attribute muss größer als :value Kilobytes sein.', + 'numeric' => ':attribute muss größer als :value sein.', + 'string' => ':attribute muss länger als :value Zeichen sein.', + ], + 'gte' => [ + 'array' => ':attribute muss mindestens :value Elemente haben.', + 'file' => ':attribute muss größer oder gleich :value Kilobytes sein.', + 'numeric' => ':attribute muss größer oder gleich :value sein.', + 'string' => ':attribute muss mindestens :value Zeichen lang sein.', + ], + 'hex_color' => ':attribute muss eine gültige Hexadezimalfarbe sein.', + 'image' => ':attribute muss ein Bild sein.', + 'in' => 'Der gewählte Wert für :attribute ist ungültig.', + 'in_array' => ':attribute muss in :other vorkommen.', + 'in_array_keys' => ':attribute muss mindestens einen der folgenden Schlüssel enthalten: :values.', + 'integer' => ':attribute muss eine ganze Zahl sein.', + 'ip' => ':attribute muss eine gültige IP-Adresse sein.', + 'ipv4' => ':attribute muss eine gültige IPv4-Adresse sein.', + 'ipv6' => ':attribute muss eine gültige IPv6-Adresse sein.', + 'json' => ':attribute muss ein gültiger JSON-String sein.', + 'list' => ':attribute muss eine Liste sein.', + 'lowercase' => ':attribute darf nur Kleinbuchstaben enthalten.', + 'lt' => [ + 'array' => ':attribute muss weniger als :value Elemente haben.', + 'file' => ':attribute muss kleiner als :value Kilobytes sein.', + 'numeric' => ':attribute muss kleiner als :value sein.', + 'string' => ':attribute muss kürzer als :value Zeichen sein.', + ], + 'lte' => [ + 'array' => ':attribute darf nicht mehr als :value Elemente haben.', + 'file' => ':attribute muss kleiner oder gleich :value Kilobytes sein.', + 'numeric' => ':attribute muss kleiner oder gleich :value sein.', + 'string' => ':attribute darf maximal :value Zeichen lang sein.', + ], + 'mac_address' => ':attribute muss eine gültige MAC-Adresse sein.', + 'max' => [ + 'array' => ':attribute darf nicht mehr als :max Elemente haben.', + 'file' => ':attribute darf nicht größer als :max Kilobytes sein.', + 'numeric' => ':attribute darf nicht größer als :max sein.', + 'string' => ':attribute darf maximal :max Zeichen lang sein.', + ], + 'max_digits' => ':attribute darf nicht mehr als :max Ziffern haben.', + 'mimes' => ':attribute muss eine Datei des Typs :values sein.', + 'mimetypes' => ':attribute muss eine Datei des Typs :values sein.', + 'min' => [ + 'array' => ':attribute muss mindestens :min Elemente haben.', + 'file' => ':attribute muss mindestens :min Kilobytes groß sein.', + 'numeric' => ':attribute muss mindestens :min sein.', + 'string' => ':attribute muss mindestens :min Zeichen lang sein.', + ], + 'min_digits' => ':attribute muss mindestens :min Ziffern haben.', + 'missing' => ':attribute muss fehlen.', + 'missing_if' => ':attribute muss fehlen, wenn :other :value ist.', + 'missing_unless' => ':attribute muss fehlen, außer :other ist :value.', + 'missing_with' => ':attribute muss fehlen, wenn :values vorhanden ist.', + 'missing_with_all' => ':attribute muss fehlen, wenn :values vorhanden sind.', + 'multiple_of' => ':attribute muss ein Vielfaches von :value sein.', + 'not_in' => 'Der gewählte Wert für :attribute ist ungültig.', + 'not_regex' => 'Das Format von :attribute ist ungültig.', + 'numeric' => ':attribute muss eine Zahl sein.', + 'password' => [ + 'letters' => ':attribute muss mindestens einen Buchstaben enthalten.', + 'mixed' => ':attribute muss mindestens einen Groß- und einen Kleinbuchstaben enthalten.', + 'numbers' => ':attribute muss mindestens eine Zahl enthalten.', + 'symbols' => ':attribute muss mindestens ein Sonderzeichen enthalten.', + 'uncompromised' => ':attribute ist in einem Datenleck aufgetaucht. Bitte ein anderes :attribute wählen.', + ], + 'present' => ':attribute muss vorhanden sein.', + 'present_if' => ':attribute muss vorhanden sein, wenn :other :value ist.', + 'present_unless' => ':attribute muss vorhanden sein, außer :other ist :value.', + 'present_with' => ':attribute muss vorhanden sein, wenn :values vorhanden ist.', + 'present_with_all' => ':attribute muss vorhanden sein, wenn :values vorhanden sind.', + 'prohibited' => ':attribute ist unzulässig.', + 'prohibited_if' => ':attribute ist unzulässig, wenn :other :value ist.', + 'prohibited_if_accepted' => ':attribute ist unzulässig, wenn :other akzeptiert ist.', + 'prohibited_if_declined' => ':attribute ist unzulässig, wenn :other abgelehnt ist.', + 'prohibited_unless' => ':attribute ist unzulässig, außer :other ist in :values.', + 'prohibits' => ':attribute verhindert, dass :other vorhanden ist.', + 'regex' => 'Das Format von :attribute ist ungültig.', + 'required' => ':attribute muss ausgefüllt werden.', + 'required_array_keys' => ':attribute muss Einträge für :values enthalten.', + 'required_if' => ':attribute muss ausgefüllt werden, wenn :other :value ist.', + 'required_if_accepted' => ':attribute muss ausgefüllt werden, wenn :other akzeptiert ist.', + 'required_if_declined' => ':attribute muss ausgefüllt werden, wenn :other abgelehnt ist.', + 'required_unless' => ':attribute muss ausgefüllt werden, außer :other ist in :values.', + 'required_with' => ':attribute muss ausgefüllt werden, wenn :values vorhanden ist.', + 'required_with_all' => ':attribute muss ausgefüllt werden, wenn :values vorhanden sind.', + 'required_without' => ':attribute muss ausgefüllt werden, wenn :values nicht vorhanden ist.', + 'required_without_all' => ':attribute muss ausgefüllt werden, wenn keines von :values vorhanden ist.', + 'same' => ':attribute und :other müssen übereinstimmen.', + 'size' => [ + 'array' => ':attribute muss genau :size Elemente enthalten.', + 'file' => ':attribute muss genau :size Kilobytes groß sein.', + 'numeric' => ':attribute muss genau :size sein.', + 'string' => ':attribute muss genau :size Zeichen lang sein.', + ], + 'starts_with' => ':attribute muss mit einem der folgenden Werte beginnen: :values.', + 'string' => ':attribute muss eine Zeichenkette sein.', + 'timezone' => ':attribute muss eine gültige Zeitzone sein.', + 'unique' => ':attribute ist bereits vergeben.', + 'uploaded' => ':attribute konnte nicht hochgeladen werden.', + 'uppercase' => ':attribute darf nur Großbuchstaben enthalten.', + 'url' => ':attribute muss eine gültige URL sein.', + 'ulid' => ':attribute muss eine gültige ULID sein.', + 'uuid' => ':attribute muss eine gültige UUID sein.', + + 'custom' => [ + 'attribute-name' => [ + 'rule-name' => 'custom-message', + ], + ], + + 'attributes' => [ + 'name' => 'Name', + 'ip' => 'IP-Adresse oder Hostname', + 'ssh_port' => 'SSH-Port', + 'sshPort' => 'SSH-Port', + 'username' => 'Benutzername', + 'password' => 'Passwort', + 'password_confirmation' => 'Passwort-Bestätigung', + 'current_password' => 'aktuelles Passwort', + 'current' => 'aktuelles Passwort', + 'email' => 'E-Mail-Adresse', + 'secret' => 'Zugangsdaten', + 'passphrase' => 'Schlüssel-Passphrase', + 'credentialName' => 'Zugangs-Name', + 'credential_name' => 'Zugangs-Name', + 'domainInput' => 'Domain', + 'code' => 'Code', + 'maxretry' => 'Maximale Fehlversuche', + 'bantime' => 'Bann-Dauer', + 'findtime' => 'Zeitfenster', + 'ignoreip' => 'Whitelist', + 'upload' => 'Datei', + 'path' => 'Pfad', + ], +]; diff --git a/lang/en/validation.php b/lang/en/validation.php new file mode 100644 index 0000000..01f0d6e --- /dev/null +++ b/lang/en/validation.php @@ -0,0 +1,191 @@ + '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.', + 'any_of' => 'The :attribute field is invalid.', + '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' => [ + '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.', + 'can' => 'The :attribute field contains an unauthorized value.', + 'confirmed' => 'The :attribute field confirmation does not match.', + 'contains' => 'The :attribute field is missing a required value.', + '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_contain' => 'The :attribute field must not contain any of the following: :values.', + '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.', + 'encoding' => 'The :attribute field must be encoded in :encoding.', + '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.', + '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.', + 'in_array' => 'The :attribute field must exist in :other.', + 'in_array_keys' => 'The :attribute field must contain at least one of the following keys: :values.', + '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' => [ + '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.', + ], + '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' => [ + '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.', + '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.', + '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_if_accepted' => 'The :attribute field is prohibited when :other is accepted.', + 'prohibited_if_declined' => 'The :attribute field is prohibited when :other is declined.', + '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 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 field must match :other.', + 'size' => [ + '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.', + ], + '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.', + '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' => [ + 'attribute-name' => [ + 'rule-name' => 'custom-message', + ], + ], + + 'attributes' => [ + 'name' => 'name', + 'ip' => 'IP address or hostname', + 'ssh_port' => 'SSH port', + 'sshPort' => 'SSH port', + 'username' => 'username', + 'password' => 'password', + 'password_confirmation' => 'password confirmation', + 'current_password' => 'current password', + 'current' => 'current password', + 'email' => 'email address', + 'secret' => 'credentials', + 'passphrase' => 'key passphrase', + 'credentialName' => 'access name', + 'credential_name' => 'access name', + 'domainInput' => 'domain', + 'code' => 'code', + 'maxretry' => 'max retries', + 'bantime' => 'ban time', + 'findtime' => 'time window', + 'ignoreip' => 'whitelist', + 'upload' => 'file', + 'path' => 'path', + ], +]; diff --git a/tests/Feature/ValidationMessagesTest.php b/tests/Feature/ValidationMessagesTest.php new file mode 100644 index 0000000..334c310 --- /dev/null +++ b/tests/Feature/ValidationMessagesTest.php @@ -0,0 +1,31 @@ +setLocale('de'); + $v = Validator::make( + ['name' => '', 'email' => 'nope', 'sshPort' => 'x'], + ['name' => 'required', 'email' => 'email', 'sshPort' => 'integer'], + ); + + $this->assertStringContainsString('muss ausgefüllt werden', $v->errors()->first('name')); + $this->assertStringContainsString('gültige E-Mail-Adresse', $v->errors()->first('email')); + // localized attribute label from the `attributes` array + $this->assertStringContainsString('SSH-Port', $v->errors()->first('sshPort')); + } + + public function test_messages_localized_in_english(): void + { + app()->setLocale('en'); + $v = Validator::make(['name' => ''], ['name' => 'required']); + + $this->assertStringContainsString('is required', $v->errors()->first('name')); + } +}