Yii Framework Forum: Whats the best boolean field validator? - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Whats the best boolean field validator? Rate Topic: -----

#1 User is offline   Ismael 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 163
  • Joined: 02-June 09
  • Location:Brazil

Posted 09 June 2009 - 10:57 AM

It's very simple.

The field in the table is a tinyint(1). It stores 0 or 1 (not null in my case).

Looking here: http://www.yiiframew.../api/CValidator

I would like to know which approach is better?

I thought using the match: CRegularExp​ressionValidator with the regular exp​ression: '/^(0|1)$/'

I'd like some opinion.
0

#2 User is offline   qiang 

  • Yii Project Lead
  • Yii
  • Group: Yii Dev Team
  • Posts: 5,750
  • Joined: 04-October 08
  • Location:DC, USA

Posted 09 June 2009 - 10:14 PM

You can use: array('attribute', 'in', 'range'=>array(0,1))
0

#3 User is offline   Ismael 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 163
  • Joined: 02-June 09
  • Location:Brazil

Posted 10 June 2009 - 08:10 AM

Well point.

It's easer than "match" method.

Thanks.
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users