English 中文(简体)
验证模型价值不成例外。
原标题:Validating model values does not throw an exception
  • 时间:2012-04-10 11:28:09
  •  标签:
  • php
  • kohana

我在Kohaana ORM的验证模式方面遇到问题,它应当抛弃一个ORM_Validation_。 然而,例外并不例外。 我正试图确认一个电子邮件地址。

模型_Emailaddress

public function rules()
{
    return array(
         emailaddress  => array(
            array(
                 Valid::email 
            ),
        ),
    );
}

主计长 试验

public function action_valid()
    {
        $email = ORM::factory( emailaddress );

        $email->emailaddress =  test ;

        try
        {
            $email->create();

        }
        catch(ORM_Validation_Exception $e)
        {
            echo Debug::dump($e->errors());
        }
    }

这个例子应当向屏幕上丢下一个有错误的阵列,而只是在没有进一步通知的情况下拯救了电子邮件地址。

当我改变Valid:不发电子邮件时,它就没有例外。 经过一些欺骗之后,我发现Valid:电子邮箱返回是假的。

EDIT:正如一些人所说的那样,改变Valid:电子邮箱不能使用。 而且,当我把货物从电子邮件方法中撤出时,将停止执行。

最佳回答

经历了一些沉重的、重的gg积 我发现,Kohaana鉴定班中包含一只 b子,加上S-35.3.3。 它应当发挥作用,但它确实如此。

在Kohaana_Validation:check()

变化

$data[$field] = Arr::get($this, $field);

页: 1

$data[$field] = Arr::get($this->_data, $field);

在Kohaana_Validation:errors()

变化

 :value  => Arr::get($this, $field),

页: 1

 :value  => Arr::get($this->_data, $field),
问题回答

oop. How about Just use:

  email  insert   Valid::email 

除()方法外,更好的使用:





相关问题
Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

定值美元

如何确认来自正确来源的数字。

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...

热门标签