引自here:
my $result = FormValidator::Simple->check( $query => [
param1 => ['NOT_BLANK', 'ASCII', ['LENGTH', 2, 5]],
param2 => ['NOT_BLANK', 'INT' ],
mail1 => ['NOT_BLANK', 'EMAIL_LOOSE'],
mail2 => ['NOT_BLANK', 'EMAIL_LOOSE'],
{ mails => ['mail1', 'mail2' ] } => ['DUPLICATION'],
{ date => ['year', 'month', 'day'] } => ['DATE'],
] );
IMO应该是:
my $result = FormValidator::Simple->check( $query => {
...
} );
为什么FormValidator::Simple更喜欢使用数组进行哈希?
答案 0 :(得分:4)
您是否建议您能够使用
my $result = FormValidator::Simple->check( $query => {
param1 => ['NOT_BLANK', 'ASCII', ['LENGTH', 2, 5]],
param2 => ['NOT_BLANK', 'INT' ],
mail1 => ['NOT_BLANK', 'EMAIL_LOOSE'],
mail2 => ['NOT_BLANK', 'EMAIL_LOOSE'],
{ mails => ['mail1', 'mail2' ] } => ['DUPLICATION'],
{ date => ['year', 'month', 'day'] } => ['DATE'],
} );
那将通过以下
{
param1 => ['NOT_BLANK', 'ASCII', ['LENGTH', 2, 5]],
param2 => ['NOT_BLANK', 'INT' ],
mail1 => ['NOT_BLANK', 'EMAIL_LOOSE'],
mail2 => ['NOT_BLANK', 'EMAIL_LOOSE'],
'HASH(0x2aaffc)' => ['DUPLICATION'],
'HASH(0x32aff4)' => ['DATE'],
}
缺少很多信息。