From 492cfec0041bfa2f6246e7123270e29594bc871a Mon Sep 17 00:00:00 2001 From: Dave Roverts Date: Sun, 2 Jan 2022 20:44:06 +0100 Subject: [PATCH] fix(AirportImport): fix majority of airports not importing Initially, only coordinates with 6 decimals where accepted, now it's increased to 10 --- app/Http/Requests/Airport/Admin/StoreAirport.php | 4 ++-- app/Http/Requests/Airport/Admin/UpdateAirport.php | 4 ++-- app/Imports/AirportsImport.php | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/Http/Requests/Airport/Admin/StoreAirport.php b/app/Http/Requests/Airport/Admin/StoreAirport.php index da8f5c06..986dd985 100644 --- a/app/Http/Requests/Airport/Admin/StoreAirport.php +++ b/app/Http/Requests/Airport/Admin/StoreAirport.php @@ -17,8 +17,8 @@ public function rules() 'icao' => 'required:string|unique:airports|size:4', 'iata' => 'required:string|unique:airports,iata|size:3', 'name' => 'required:string', - 'latitude' => ['required', 'regex:/^(\+|-)?(?:90(?:(?:\.0{1,6})?)|(?:[0-9]|[1-8][0-9])(?:(?:\.[0-9]{1,6})?))$/'], - 'longitude' => ['required', 'regex:/^(\+|-)?(?:180(?:(?:\.0{1,6})?)|(?:[0-9]|[1-9][0-9]|1[0-7][0-9])(?:(?:\.[0-9]{1,6})?))$/'], + 'latitude' => ['required', 'regex:/^[-]?((([0-8]?[0-9])(\.(\d{1,10}))?)|(90(\.0+)?))$/'], + 'longitude' => ['required', 'regex:/^[-]?((((1[0-7][0-9])|([0-9]?[0-9]))(\.(\d{1,10}))?)|180(\.0+)?)/'], ]; } diff --git a/app/Http/Requests/Airport/Admin/UpdateAirport.php b/app/Http/Requests/Airport/Admin/UpdateAirport.php index 40b7c387..de0ce63e 100644 --- a/app/Http/Requests/Airport/Admin/UpdateAirport.php +++ b/app/Http/Requests/Airport/Admin/UpdateAirport.php @@ -17,8 +17,8 @@ public function rules() 'icao' => 'required:string|between:4,4', 'iata' => 'required:string|between:3,3', 'name' => 'required:string', - 'latitude' => ['required', 'regex:/^(\+|-)?(?:90(?:(?:\.0{1,6})?)|(?:[0-9]|[1-8][0-9])(?:(?:\.[0-9]{1,6})?))$/'], - 'longitude' => ['required', 'regex:/^(\+|-)?(?:180(?:(?:\.0{1,6})?)|(?:[0-9]|[1-9][0-9]|1[0-7][0-9])(?:(?:\.[0-9]{1,6})?))$/'], + 'latitude' => ['required', 'regex:/^[-]?((([0-8]?[0-9])(\.(\d{1,10}))?)|(90(\.0+)?))$/'], + 'longitude' => ['required', 'regex:/^[-]?((((1[0-7][0-9])|([0-9]?[0-9]))(\.(\d{1,10}))?)|180(\.0+)?)/'], ]; } diff --git a/app/Imports/AirportsImport.php b/app/Imports/AirportsImport.php index 385ff90a..209bd02a 100644 --- a/app/Imports/AirportsImport.php +++ b/app/Imports/AirportsImport.php @@ -42,8 +42,8 @@ public function rules(): array 'icao' => ['required', 'string', Rule::unique('airports', 'icao')], 'iata' => ['required', 'string', Rule::unique('airports', 'iata')], 'name' => ['required', 'string'], - 'lat' => ['required', 'regex:/^(\+|-)?(?:90(?:(?:\.0{1,6})?)|(?:[0-9]|[1-8][0-9])(?:(?:\.[0-9]{1,6})?))$/'], - 'lon' => ['required', 'regex:/^(\+|-)?(?:180(?:(?:\.0{1,6})?)|(?:[0-9]|[1-9][0-9]|1[0-7][0-9])(?:(?:\.[0-9]{1,6})?))$/'], + 'lat' => ['required', 'regex:/^[-]?((([0-8]?[0-9])(\.(\d{1,10}))?)|(90(\.0+)?))$/'], + 'lon' => ['required', 'regex:/^[-]?((((1[0-7][0-9])|([0-9]?[0-9]))(\.(\d{1,10}))?)|180(\.0+)?)/'], ]; }