From 8fb763a27dc23524919b7ee0c3136293ee36c06a Mon Sep 17 00:00:00 2001 From: Gustavo Novaro Date: Sun, 3 Mar 2024 22:00:58 +0100 Subject: [PATCH] refactor(bank): Save bank validation - Adding composer extra validation for BIC, IBAN --- .../Controllers/Bank/BankSaveController.php | 9 ++ composer.json | 1 + composer.lock | 86 ++++++++++++++++++- 3 files changed, 95 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/Bank/BankSaveController.php b/app/Http/Controllers/Bank/BankSaveController.php index 0a9fba4f..d22fbb6a 100755 --- a/app/Http/Controllers/Bank/BankSaveController.php +++ b/app/Http/Controllers/Bank/BankSaveController.php @@ -7,11 +7,20 @@ use App\Models\Bank; use Illuminate\Http\Request; use Ramsey\Uuid\Uuid; +use Intervention\Validation\Rules\Bic; class BankSaveController { public function save(Request $request) { + $request->validate([ + 'name' => 'required', + 'country_id' => 'required', + 'bic' => 'required|bic|unique:bank', + 'email' => 'nullable|email', + 'website' => 'nullable|url', + ]); + if (empty($request->uuid)) { $bank = new Bank(); $bank->created_at = now(); diff --git a/composer.json b/composer.json index 43ce54b7..cad64b56 100755 --- a/composer.json +++ b/composer.json @@ -26,6 +26,7 @@ "h4cc/wkhtmltoimage-i386": "0.12.x", "h4cc/wkhtmltopdf-amd64": "0.12.x", "h4cc/wkhtmltopdf-i386": "0.12.x", + "intervention/validation": "^4.1", "laravel/framework": "^10.10", "laravel/helpers": "^1.6", "laravel/sanctum": "^3.3", diff --git a/composer.lock b/composer.lock index 4cb6c0cd..5518a91d 100755 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "8fe5317b976a1a5f3dd113820c4d81e9", + "content-hash": "f71cb34e3fbe11471a8a4ff770513119", "packages": [ { "name": "akaunting/laravel-money", @@ -2679,6 +2679,90 @@ }, "time": "2021-07-21T13:50:14+00:00" }, + { + "name": "intervention/validation", + "version": "4.1.0", + "source": { + "type": "git", + "url": "https://github.com/Intervention/validation.git", + "reference": "b607fa1da132008907f074434169ad115c20e455" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Intervention/validation/zipball/b607fa1da132008907f074434169ad115c20e455", + "reference": "b607fa1da132008907f074434169ad115c20e455", + "shasum": "" + }, + "require": { + "ext-mbstring": "*", + "illuminate/validation": "^10|^11", + "php": "^8.1" + }, + "require-dev": { + "phpstan/phpstan": "^1", + "phpunit/phpunit": "^10.0", + "slevomat/coding-standard": "~8.0", + "squizlabs/php_codesniffer": "^3.8", + "symfony/uid": "^5.1|^6.2" + }, + "type": "library", + "extra": { + "laravel": { + "providers": [ + "Intervention\\Validation\\Laravel\\ValidationServiceProvider" + ] + } + }, + "autoload": { + "psr-4": { + "Intervention\\Validation\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Oliver Vogel", + "email": "oliver@intervention.io", + "homepage": "https://intervention.io/" + } + ], + "description": "Additional validation rules for the Laravel framework", + "homepage": "https://validation.intervention.io/", + "keywords": [ + "BIC", + "IBAN", + "ISBN", + "ISIN", + "base64", + "creditcard", + "data-url", + "ean", + "gtin", + "laravel", + "luhn", + "ulid", + "validation", + "validator" + ], + "support": { + "issues": "https://github.com/Intervention/validation/issues", + "source": "https://github.com/Intervention/validation/tree/4.1.0" + }, + "funding": [ + { + "url": "https://paypal.me/interventionio", + "type": "custom" + }, + { + "url": "https://github.com/Intervention", + "type": "github" + } + ], + "time": "2024-03-03T09:33:39+00:00" + }, { "name": "jean85/pretty-package-versions", "version": "2.0.5",