You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
$validator = new Validator;
// To set attribute alias, you should use `make` instead `validate`.
$validation->make([
'province_id' => $_POST['province_id'],
'district_id' => $_POST['district_id']
], [
'province_id' => 'required|numeric',
'district_id' => 'required|numeric'
]);
// now you can set aliases to the translated string:
$validation->setAliases([
'province_id' => 'Provinz',
'district_id' => 'Bezirk'
]);
$validation->setMessages([
'required' => ':attribute ist erforderlich',
]);
// then validate it
$validation->validate();
Now if province_id value is empty, error message would be 'Bezirk ist erforderlich'.
Activity
superdav42 commentedon Nov 19, 2025
Yes, you can use aliases:
Example:
Now if province_id value is empty, error message would be 'Bezirk ist erforderlich'.