Added ZT to System, more ZT validation on zone

This commit is contained in:
Deon George
2021-06-27 01:15:19 +10:00
parent dfc4e305f1
commit 9897c928d9
4 changed files with 35 additions and 9 deletions

View File

@@ -35,11 +35,27 @@ class ZoneController extends Controller
})
],
'system_id' => 'required|exists:systems,id',
'zt_id' => 'nullable|size:10|regex:/^([A-Fa-f0-9]){10}$/',
'zt_id' => 'nullable|size:16|regex:/^([A-Fa-f0-9]){16}$/|unique:zones,zt_id,'.($o->exists ? $o->id : 0),
'zt_ipv4' => 'nullable|ipv4',
'zt_ipv4_mask' => 'nullable|numeric|lte:31',
'zt_ipv4_mask' => [
'nullable','numeric','lte:31','required_with:zt_ipv4',
Rule::unique('zones')->where(function ($query) use ($request,$o) {
return $query->where('zt_ipv4',$request->post('zt_ipv4'))
->where('zt_ipv4_mask',$request->post('zt_ipv4_mask'))
->when($o->exists,function($query) use ($o) {
return $query->where('id','<>',$o->id);
});
})],
'zt_ipv6' => 'nullable|ipv6',
'zt_ipv6_mask' => 'nullable|numeric|lte:112',
'zt_ipv6_mask' => [
'nullable','numeric','lte:112','required_with:zt_ipv6',
Rule::unique('zones')->where(function ($query) use ($request,$o) {
return $query->where('zt_ipv6',$request->post('zt_ipv6'))
->where('zt_ipv6_mask',$request->post('zt_ipv6_mask'))
->when($o->exists,function($query) use ($o) {
return $query->where('id','<>',$o->id);
});
})],
'active' => 'required|boolean',
]);