2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

CakePHPのバリデーションのつけ方メモ

Posted at
Model
<?php

class Post extends AppModel{
	
	public $validate = array(
		'title' => array(
			'rule' => 'notEmpty'
			//'allowEmpty' => false
		),
		'body' => array(
			'rule' => 'notEmpty'
			//'allowEmpty' => false
		)
	);
	
	/*
	public $validate = array(
		'name' => array(
			'rule' => array('between',0,10),
			'required' => true,
			'allowEmpty' => false,
			'message' => '10文字以内で必ず入力して下さい'
		),
		'email' => array(
			'rule' => 'email',
			'required' => true,
			'allowEmpty' => false,
			'message' => 'メールアドレスの形式で必ず入力して下さい'
		),
		'password' => array(
			'rule' => 'alphaNumeric',
			'required' => true,
			'allowEmpty' => false,
			'message' => '必ず入力して下さい'
		)
	);
	*/
}
2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?