laravel Validation
Onga.inc
<?php $validator = Validator::make( array('name' => 'Dayle'), array('name' => 'required|min:5') ); ?>
基本的な使用方法
<?php if ($validator->fails()) { // The given data did not pass validation } $messages = $validator->messages(); ?>
バリデート結果の取得
<?php foreach ($messages->all() as $message) { // } ?>
バリデートメッセージの使用例
<?php if ($messages->has('email')) { // } ?>
バリデートメッセージの使用例
<?php exists:table,column ?>
指定するテーブルに存在するか確認する。
<?php 'photo' => 'mimes:jpeg,bmp,png' ?>
イメージタイプのバリデート
<?php 'email' => 'unique:users' ?>
テーブル内で、値がユニークかを確認する。
<?php $messages = array( 'same' => 'The :attribute and :other must match.', 'size' => 'The :attribute must be exactly :size.', 'between' => 'The :attribute must be between :min - :max.', 'in' => 'The :attribute must be one of the following types: :values', ); ?>
カスタムエラーメッセージ