ここで書き方を読むことができます:
http://framework.zend.com/manual/en/zend.validate.writing_validators.html
class MyValid_Float extends Zend_Validate_Abstract
{
1) これはどこに置くべきですか?
アプリケーション/デフォルト/バリデーター? アプリケーション/ビュー/ヘルパー/... ?
2) アプリケーションのどこかにこれを登録する必要がありますか?
更新: これが私のブートストラップの例です:
include_once 'config_root.php';
set_include_path ( $PATH );
require_once 'Initializer.php';
require_once "Zend/Loader.php";
require_once 'Zend/Loader/Autoloader.php';
// Set up autoload.
$loader = Zend_Loader_Autoloader::getInstance ();
$loader->setFallbackAutoloader ( true );
$loader->suppressNotFoundWarnings ( false );
// Prepare the front controller.
$frontController = Zend_Controller_Front::getInstance ();
$frontController->throwExceptions(true);
$frontController->registerPlugin ( new Initializer ( PROJECT_ENV ) );
// Dispatch the request using the front controller.
try {
$frontController->dispatch ();
} catch ( Exception $exp ) {
$contentType = "text/html";
header ( "Content-Type: $contentType; charset=UTF-8" );
echo "an unexpected error occurred.";
echo "<h2>Unexpected Exception: " . $exp->getMessage () . "</h2><br /><pre>";
echo $exp->getTraceAsString ();
}
SO、ここに追加する必要がありますか:
$resourceLoader = new Zend_Loader_Autoloader_Resource(array(
'basePath' => APPLICATION_PATH,
'namespace' => '',
));
$resourceLoader->addResourceType('validate', 'validators/', 'My_Validate_');
次に、ファイル IN を作成する必要があります (この構成ではデフォルト モジュールを使用していることに注意してください):
アプリケーション/デフォルト/バリデーター/ValidateSpam.php
そして、validateSpam.php には次のようなものがあります。
class My_Validate_Spam extends Zend_Validate_Abstract {
確認していただけますか?
ありがとう