Server IP : 185.86.78.101 / Your IP : 216.73.216.124 Web Server : Apache System : Linux 675867-vds-valikoshka1996.gmhost.pp.ua 5.4.0-150-generic #167-Ubuntu SMP Mon May 15 17:35:05 UTC 2023 x86_64 User : www ( 1000) PHP Version : 7.4.33 Disable Function : passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /www/wwwroot/mifepriston.org/vendor/yiisoft/yii2/validators/ |
Upload File : |
<?php /** * @link https://www.yiiframework.com/ * @copyright Copyright (c) 2008 Yii Software LLC * @license https://www.yiiframework.com/license/ */ namespace yii\validators; use yii\helpers\Json; /** * This class converts the attribute value(s) to string(s) and strip characters. * * @since 2.0.46 */ class TrimValidator extends Validator { /** * @var string The list of characters to strip, with `..` can specify a range of characters. * For example, set '\/ ' to normalize path or namespace. */ public $chars; /** * @var bool Whether the filter should be skipped if an array input is given. * If true and an array input is given, the filter will not be applied. */ public $skipOnArray = false; /** * @inheritDoc */ public $skipOnEmpty = false; /** * @inheritDoc */ public function validateAttribute($model, $attribute) { $value = $model->$attribute; if (!$this->skipOnArray || !is_array($value)) { $model->$attribute = is_array($value) ? array_map([$this, 'trimValue'], $value) : $this->trimValue($value); } } /** * Converts given value to string and strips declared characters. * * @param mixed $value the value to strip * @return string */ protected function trimValue($value) { return $this->isEmpty($value) ? '' : trim((string) $value, $this->chars ?: " \n\r\t\v\x00"); } /** * @inheritDoc */ public function clientValidateAttribute($model, $attribute, $view) { if ($this->skipOnArray && is_array($model->$attribute)) { return null; } ValidationAsset::register($view); $options = $this->getClientOptions($model, $attribute); return 'value = yii.validation.trim($form, attribute, ' . Json::htmlEncode($options) . ', value);'; } /** * @inheritDoc */ public function getClientOptions($model, $attribute) { return [ 'skipOnArray' => (bool) $this->skipOnArray, 'skipOnEmpty' => (bool) $this->skipOnEmpty, 'chars' => $this->chars ?: false, ]; } }