mojaviでは最初から、
- メールアドレスであるかを評価
- 数字であるかを評価
などなど、送信されたデータを検証するValidatorクラスがいろいろあるから必要無いかもしれないけど、
mojaviのソースコードを学ぶ事もかねて、指定した正規表現に当てはまるかどうかを検証するValidatorクラスを作ってみました。
使うアクションの中でこんな感じで記述
require_once(VALIDATOR_DIR . 'RegularExpressionValidator.class.php');
function registerValidators(&$validatorManager, &$controller, &$request, &$user)
{
$validator =& new RegularExpressionValidator($controller);
$criteria = array('error' => 'errormassage', 'regular_expression' => 'hogehoge');
$validator->initialize($criteria);
$validatorManager->register('param', $validator);
}
errormassage …当てはまらなかった時のエラーメッセージ
hogehoge …正規表現を記述(preg_match()で検証します)

Appreciating the time and energy you put into your site and in depth information you present. It’s great to come across a blog every once in a while that isn’t the same outdated rehashed material. Wonderful read! I’ve bookmarked your site and I’m including your RSS feeds to my Google account.