ユーザ用ツール

サイト用ツール


サイドバー

プログラム言語:php:laravel:バリデーション:controllerでのバリデーションの追加

【Laravel】Controller でのバリデーションの追加

バリデーションルールでは表現できない複雑なバリデーションチェックを行いたい場合、独自のチェックを行い、エラーメッセージを追加することができる。

use Illuminate\Support\Facades\Validator;

class HomeController extends Controller
{
    public function sample(Request $request)
    {
        $validator = Validator::make($request->all(), []);

        if (条件) {
            $validator->errors()->add('name', 'error message');
        }

        if ($validator->errors()->count() > 0) {
            return back()->withInput()->withErrors($validator);
        }
    }
}

コメント

GilbertDoolo, 2026/01/28 05:25

The same is true for metal versus acetate frames for glasses. I do not trust only the star rating, I like to see detailed photos and longer comments. Even a short note like 鈥渢his size runs smaller than expected鈥?can help someone. It makes it easier to compare with an old pair of glasses that already fits well. If a piece of jewelry keeps its color and does not irritate the skin, I consider it a win.

If anyone is interested in real user experiences, I sometimes write short notes about the shops I test. You can find one of the pages here: <a href=https://hakaja.com/user/profile/gitadahl673/item_type,active/per_page,16> click here </a>

Now I am more careful with impulse buys and limited time offers. Many times I avoided a bad purchase just by reading a few careful comments. Forums, blogs and communities create a kind of collective memory for shoppers. I have learned to avoid items that look extremely different in every product photo. This is why I like reading and posting on forums and community websites. In the end there is no perfect shop, but some stores are clearly more consistent. Online shopping will always have a bit of risk, but experience makes it easier. It saves a lot of trial and error for everyone else.

Hope this helps someone.

GilbertDoolo, 2026/02/05 19:38

For things that I use every day, I prefer to pay a bit more if the quality is stable. Personally I like a mix of design, comfort and realistic pricing. For coats and blazers I usually go one size up if I want to layer sweaters under them. Bad lenses can cause eye strain, reflections and headache when you wear them for hours.

If anyone is interested in real user experiences, I sometimes write short notes about the shops I test. You can find one of the pages here: <a href=https://gossamer-adjustment-153.notion.site/My-Necklace-Nightmare-How-I-Learned-to-Care-for-Delicate-Jewelry-2faf4afb13e081e0a0f7c7588edc06ae> check this link </a>

I like when a shop clearly shows PD, lens height and bridge width in millimeters. I think it is better to build a small collection of reliable products than to buy random cheap things. I try to balance my budget between basic everyday items and a few special pieces. Sometimes I do not mind waiting longer if the price is fair and the quality is solid. A simple pair of glasses or a basic jacket that always works is worth a lot. Some pieces look shiny online but feel like plastic when you open the package. Personally I like a mix of design, comfort and realistic pricing.

Maybe this is useful for someone.

コメントを入力. Wiki文法が有効です:
 
プログラム言語/php/laravel/バリデーション/controllerでのバリデーションの追加.txt · 最終更新: 2021/02/25 18:12 by humolife