当前位置: 首页>>代码示例>>PHP>>正文


PHP Validate::number方法代码示例

本文整理汇总了PHP中Validate::number方法的典型用法代码示例。如果您正苦于以下问题:PHP Validate::number方法的具体用法?PHP Validate::number怎么用?PHP Validate::number使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Validate的用法示例。


在下文中一共展示了Validate::number方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: validate

 /**
  * @return bool
  * @throws Exception
  */
 public function validate()
 {
     if ($this->id && !Validate::number($this->id)) {
         throw new Exception('Invalid Id!');
     }
     if ($this->name && !Validate::string($this->name)) {
         throw new Exception('Invalid Name');
     }
     if ($this->language && !Validate::string($this->language)) {
         throw new Exception('Invalid Language');
     }
     if ($this->genre && !Validate::string($this->genre)) {
         throw new Exception('Invalid Genre');
     }
     if ($this->author && !Validate::string($this->author)) {
         throw new Exception('Invalid Author');
     }
     if ($this->publish_date && !Validate::number($this->publish_date)) {
         if (!Validate::date($this->publish_date)) {
             throw new Exception('Invalid Publish Date');
         }
         $this->publish_date = strtotime($this->publish_date);
     }
     return true;
 }
开发者ID:alfytu,项目名称:booklibrary,代码行数:29,代码来源:Book.php

示例2: prepare

 function prepare($args)
 {
     parent::prepare($args);
     $nickname_arg = $this->arg('nickname');
     $nickname = common_canonical_nickname($nickname_arg);
     // Permanent redirect on non-canonical nickname
     if ($nickname_arg != $nickname) {
         $args = array('nickname' => $nickname);
         if ($this->arg('page') && $this->arg('page') != 1) {
             $args['page'] = $this->arg['page'];
         }
         common_redirect(common_local_url($this->trimmed('action'), $args), 301);
         return false;
     }
     $this->user = User::staticGet('nickname', $nickname);
     if (!$this->user) {
         $this->clientError(_m('No such user.'), 404);
         return false;
     }
     $this->profile = $this->user->getProfile();
     if (!$this->profile) {
         $this->serverError(_m('User has no profile.'));
         return false;
     }
     $page = $this->trimmed('page');
     if (!empty($page) && Validate::number($page)) {
         $this->page = $page + 0;
     } else {
         $this->page = 1;
     }
     $this->notices = empty($this->tag) ? $this->user->getNotices(($this->page - 1) * NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1) : $this->user->getTaggedNotices($this->tag, ($this->page - 1) * NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1, 0, 0, null);
     return true;
 }
开发者ID:stevertiqo,项目名称:StatusNet,代码行数:33,代码来源:map.php

示例3: validate

 function validate($values)
 {
     $return = true;
     $validate = new Validate();
     if (!$validate->string($values['navn'], array('min_length' => 1))) {
         $return = false;
     }
     if (!$validate->string($values['adresse'], array('min_length' => 1))) {
         $return = false;
     }
     if (!$validate->number($values['postnr'], array('min' => 100))) {
         $return = false;
     }
     if (!$validate->string($values['postby'], array('min_length' => 1))) {
         $return = false;
     }
     if (!empty($values['email']) and !$validate->email($values['email'])) {
         $return = false;
     }
     /*
     if (isset($values['langekurser']) != "" && $values['langekurser'] != "1") $return = false;
     if (isset($values['kortekurser']) != "" && $values['kortekurser'] != "1") $return = false;
     if (isset($values['efterskole']) != "" && $values['efterskole'] != "1") $return = false;
     if (isset($values['kursuscenter']) != "" && $values['kursuscenter'] != "1") $return = false;
     */
     return $return;
 }
开发者ID:vih,项目名称:vih.dk,代码行数:27,代码来源:MaterialeBestilling.php

示例4: prepare

 function prepare($args)
 {
     parent::prepare($args);
     $nickname_arg = $this->arg('nickname');
     $nickname = Nickname::normalize($nickname_arg);
     // Permanent redirect on non-canonical nickname
     if ($nickname_arg != $nickname) {
         $args = array('nickname' => $nickname);
         if ($this->arg('page') && $this->arg('page') != 1) {
             $args['page'] = $this->arg['page'];
         }
         common_redirect(common_local_url($this->trimmed('action'), $args), 301);
     }
     $this->user = User::getKV('nickname', $nickname);
     if (!$this->user) {
         // TRANS: Client error displayed when referring to a non-existing user.
         $this->clientError(_m('No such user.'), 404);
     }
     $this->profile = $this->user->getProfile();
     if (!$this->profile) {
         // TRANS: Error message displayed when referring to a user without a profile.
         $this->serverError(_m('User has no profile.'));
     }
     $page = $this->trimmed('page');
     if (!empty($page) && Validate::number($page)) {
         $this->page = $page + 0;
     } else {
         $this->page = 1;
     }
     $this->notices = empty($this->tag) ? $this->user->getNotices(($this->page - 1) * NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1) : $this->user->getTaggedNotices($this->tag, ($this->page - 1) * NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1, 0, 0, null);
     return true;
 }
开发者ID:bashrc,项目名称:gnusocial-debian,代码行数:32,代码来源:map.php

示例5: validate

 function validate($input)
 {
     $error = array();
     if (!Validate::number($input['type'], array('min' => 1))) {
         $error[] = "type";
     }
     /*
     if (!Validate::string($input['comment'], array('format' => VALIDATE_NUM . VALIDATE_ALPHA . VALIDATE_PUNCTUATION . 'æøåâäüéèÆØÅ-#'))) {
         $error[] = "comment";
     }
     */
     if (count($error) > 0) {
         print_r($error);
         return false;
     } else {
         return true;
     }
 }
开发者ID:vih,项目名称:vih.dk,代码行数:18,代码来源:Historik.php

示例6: validate

 function validate(&$values)
 {
     // Validate site name
     if (empty($values['site']['name'])) {
         // TRANS: Client error displayed trying to save an empty site name.
         $this->clientError(_('Site name must have non-zero length.'));
     }
     // Validate email
     $values['site']['email'] = common_canonical_email($values['site']['email']);
     if (empty($values['site']['email'])) {
         // TRANS: Client error displayed trying to save site settings without a contact address.
         $this->clientError(_('You must have a valid contact email address.'));
     }
     if (!Validate::email($values['site']['email'], common_config('email', 'check_domain'))) {
         // TRANS: Client error displayed trying to save site settings without a valid contact address.
         $this->clientError(_('Not a valid email address.'));
     }
     // Validate logos
     if (!empty($values['site']['logo']) && !Validate::uri($values['site']['logo'], array('allowed_schemes' => array('http', 'https')))) {
         // TRANS: Client error displayed when a logo URL is not valid.
         $this->clientError(_('Invalid logo URL.'));
     }
     if (!empty($values['site']['ssllogo']) && !Validate::uri($values['site']['ssllogo'], array('allowed_schemes' => array('https')))) {
         // TRANS: Client error displayed when a SSL logo URL is invalid.
         $this->clientError(_('Invalid SSL logo URL.'));
     }
     // Validate timezone
     if (is_null($values['site']['timezone']) || !in_array($values['site']['timezone'], DateTimeZone::listIdentifiers())) {
         // TRANS: Client error displayed trying to save site settings without a timezone.
         $this->clientError(_('Timezone not selected.'));
         return;
     }
     // Validate language
     if (!is_null($values['site']['language']) && !in_array($values['site']['language'], array_keys(get_nice_language_list()))) {
         // TRANS: Client error displayed trying to save site settings with an invalid language code.
         // TRANS: %s is the invalid language code.
         $this->clientError(sprintf(_('Unknown language "%s".'), $values['site']['language']));
     }
     // Validate text limit
     if (!Validate::number($values['site']['textlimit'], array('min' => 0))) {
         // TRANS: Client error displayed trying to save site settings with a text limit below 0.
         $this->clientError(_('Minimum text limit is 0 (unlimited).'));
     }
     // Validate dupe limit
     if (!Validate::number($values['site']['dupelimit'], array('min' => 1))) {
         // TRANS: Client error displayed trying to save site settings with a text limit below 1.
         $this->clientError(_('Dupe limit must be one or more seconds.'));
     }
 }
开发者ID:Grasia,项目名称:bolotweet,代码行数:49,代码来源:siteadminpanel.php

示例7: validate

 function validate(&$values)
 {
     // Validate snapshot run value
     if (!in_array($values['snapshot']['run'], array('web', 'cron', 'never'))) {
         $this->clientError(_('Invalid snapshot run value.'));
     }
     // Validate snapshot frequency value
     if (!Validate::number($values['snapshot']['frequency'])) {
         $this->clientError(_('Snapshot frequency must be a number.'));
     }
     // Validate report URL
     if (!is_null($values['snapshot']['reporturl']) && !Validate::uri($values['snapshot']['reporturl'], array('allowed_schemes' => array('http', 'https')))) {
         $this->clientError(_('Invalid snapshot report URL.'));
     }
 }
开发者ID:microcosmx,项目名称:experiments,代码行数:15,代码来源:snapshotadminpanel.php

示例8: validate

 /**
  * Bruges til at validere input date.
  *
  * @return true on success
  */
 function validate($var)
 {
     $error = array();
     if (!Validate::number($var['antal'], array('min' => 1))) {
         $error[] = "antal";
     }
     if (count($error) > 0) {
         print_r($error);
         return false;
     } else {
         return true;
     }
 }
开发者ID:vih,项目名称:vih.dk,代码行数:18,代码来源:Venteliste.php

示例9: _validateAmount

 /**
  * Validate the order amount.
  *
  * Should contain no digits, as those are set with the exponent option.
  *
  * @access private
  * @return boolean true if valid, false otherwise
  */
 function _validateAmount()
 {
     $result = Validate::number($this->amount, array('decimal' => false));
     if (!$result) {
         throw new Payment_Process2_Exception("Invalid amount");
     }
     return true;
 }
开发者ID:pear,项目名称:payment_process2,代码行数:16,代码来源:Bibit.php

示例10: validate

 function validate(&$values)
 {
     // Validate biolimit
     if (!Validate::number($values['profile']['biolimit'])) {
         $this->clientError(_("Invalid bio limit. Must be numeric."));
     }
     // Validate welcome text
     if (mb_strlen($values['newuser']['welcome']) > 255) {
         $this->clientError(_("Invalid welcome text. Max length is 255 characters."));
     }
     // Validate default subscription
     if (!empty($values['newuser']['default'])) {
         $defuser = User::staticGet('nickname', trim($values['newuser']['default']));
         if (empty($defuser)) {
             $this->clientError(sprintf(_('Invalid default subscripton: \'%1$s\' is not user.'), $values['newuser']['default']));
         }
     }
 }
开发者ID:himmelex,项目名称:NTW,代码行数:18,代码来源:useradminpanel.php

示例11: validate

 function validate(&$values)
 {
     // Validate biolimit
     if (!Validate::number($values['profile']['biolimit'])) {
         // TRANS: Form validation error in user admin panel when a non-numeric character limit was set.
         $this->clientError(_('Invalid bio limit. Must be numeric.'));
     }
     // Validate welcome text
     if (mb_strlen($values['newuser']['welcome']) > 255) {
         // TRANS: Form validation error in user admin panel when welcome text is too long.
         $this->clientError(_('Invalid welcome text. Maximum length is 255 characters.'));
     }
     // Validate default subscription
     if (!empty($values['newuser']['default'])) {
         $defuser = User::getKV('nickname', trim($values['newuser']['default']));
         if (empty($defuser)) {
             $this->clientError(sprintf(_('Invalid default subscripton: "%1$s" is not a user.'), $values['newuser']['default']));
         }
     }
 }
开发者ID:bashrc,项目名称:gnusocial-debian,代码行数:20,代码来源:useradminpanel.php

示例12: _validateExpDate

 /**
  * Validate the card's expiration date.
  *
  * @return boolean true on success, false otherwise
  * @access protected
  * @author Joe Stump <joe@joestump.net>
  * @todo Fix YxK issues; an expyear of '99' will come up as valid.
  */
 function _validateExpDate()
 {
     list($month, $year) = explode('/', $this->expDate);
     if (!is_numeric($month) || !is_numeric($year)) {
         return PEAR::raiseError('Invalid expiration date provided');
     }
     $monthOptions = array('min' => 1, 'max' => 12, 'decimal' => false);
     $date = getdate();
     $yearOptions = array('min' => $date['year'], 'decimal' => false);
     if (Validate::number($month, $monthOptions) && Validate::number($year, $yearOptions)) {
         if ($month >= $date['mon'] && $year == $date['year'] || $year > $date['year']) {
             return true;
         }
     }
     return PEAR::raiseError('Invalid expiration date provided');
 }
开发者ID:J-P-Hanafin,项目名称:TimeTrex-1,代码行数:24,代码来源:CreditCard.php

示例13: _validateAmount

 /**
  * Validates the charge amount.
  *
  * Charge amount must be 8 characters long, double-precision.
  * Current min/max are rather arbitrarily set to $0.01 and $99999.99,
  * respectively.
  *
  * @return boolean true on success, false otherwise
  */
 function _validateAmount()
 {
     return Validate::number($this->amount, array('decimal' => '.', 'dec_prec' => 2, 'min' => 0.01, 'max' => 99999.99000000001));
 }
开发者ID:alachaum,项目名称:timetrex,代码行数:13,代码来源:BeanstreamEFT.php

示例14: validate

 /**
  * validate - override this to set up your validation rules
  *
  * validate the current objects values either just testing strings/numbers or
  * using the user defined validate{Row name}() methods.
  * will attempt to call $this->validate{column_name}() - expects true = ok  false = ERROR
  * you can the use the validate Class from your own methods.
  *
  * @access  public
  * @return  array of validation results or true
  */
 function validate()
 {
     require_once 'Validate.php';
     $table =& $this->_get_table();
     $ret = array();
     foreach ($table as $key => $val) {
         // ignore things that are not set. ?
         if (!isset($this->{$key})) {
             continue;
         }
         // call user defined validation
         $method = "Validate" . ucfirst($key);
         if (method_exists($this, $method)) {
             $ret[$key] = $this->{$method}();
             continue;
         }
         // if the string is empty.. assume it is ok..
         if (!strlen($this->{$key})) {
             continue;
         }
         switch ($val) {
             case DB_DATAOBJECT_STR:
                 $ret[$key] = Validate::string($this->{$key}, VALIDATE_PUNCTUATION . VALIDATE_NAME);
                 continue;
             case DB_DATAOBJECT_INT:
                 $ret[$key] = Validate::number($this->{$key}, array('decimal' => '.'));
                 continue;
         }
     }
     foreach ($ret as $key => $val) {
         if ($val == false) {
             return $ret;
         }
     }
     return true;
     // everything is OK.
 }
开发者ID:vojtajina,项目名称:sitellite,代码行数:48,代码来源:DataObject.php

示例15: doPost

 protected function doPost()
 {
     $urlshorteningservice = $this->trimmed('urlshorteningservice');
     if (!is_null($urlshorteningservice) && strlen($urlshorteningservice) > 50) {
         // TRANS: Form validation error for form "Other settings" in user profile.
         throw new ClientException(_('URL shortening service is too long (maximum 50 characters).'));
     }
     $maxurllength = $this->trimmed('maxurllength');
     if (!Validate::number($maxurllength, array('min' => -1))) {
         // TRANS: Client exception thrown when the maximum URL settings value is invalid in profile URL settings.
         throw new ClientException(_('Invalid number for maximum URL length.'));
     }
     $maxnoticelength = $this->trimmed('maxnoticelength');
     if (!Validate::number($maxnoticelength, array('min' => -1))) {
         // TRANS: Client exception thrown when the maximum notice length settings value is invalid in profile URL settings.
         throw new ClientException(_('Invalid number for maximum notice length.'));
     }
     $user = $this->scoped->getUser();
     $user->query('BEGIN');
     $original = clone $user;
     $user->urlshorteningservice = $urlshorteningservice;
     $result = $user->update($original);
     if ($result === false) {
         common_log_db_error($user, 'UPDATE', __FILE__);
         $user->query('ROLLBACK');
         // TRANS: Server error displayed when "Other" settings in user profile could not be updated on the server.
         throw new ServerException(_('Could not update user.'));
     }
     $prefs = User_urlshortener_prefs::getPrefs($user);
     $orig = null;
     if (!$prefs instanceof User_urlshortener_prefs) {
         $prefs = new User_urlshortener_prefs();
         $prefs->user_id = $user->id;
         $prefs->created = common_sql_now();
     } else {
         $orig = clone $prefs;
     }
     $prefs->urlshorteningservice = $urlshorteningservice;
     $prefs->maxurllength = $maxurllength;
     $prefs->maxnoticelength = $maxnoticelength;
     if ($orig instanceof User_urlshortener_prefs) {
         $result = $prefs->update($orig);
     } else {
         $result = $prefs->insert();
     }
     if ($result === null) {
         $user->query('ROLLBACK');
         // TRANS: Server exception thrown in profile URL settings when preferences could not be saved.
         throw new ServerException(_('Error saving user URL shortening preferences.'));
     }
     $user->query('COMMIT');
     // TRANS: Confirmation message after saving preferences.
     return _('Preferences saved.');
 }
开发者ID:bashrc,项目名称:gnusocial-debian,代码行数:54,代码来源:urlsettings.php


注:本文中的Validate::number方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。