本文整理汇总了PHP中Result::setValue方法的典型用法代码示例。如果您正苦于以下问题:PHP Result::setValue方法的具体用法?PHP Result::setValue怎么用?PHP Result::setValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Result
的用法示例。
在下文中一共展示了Result::setValue方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: isValid
public function isValid($value)
{
$result = new Result(["value" => true]);
if (is_string($value)) {
$value = trim($value);
}
if (!isset($value) || $value === null || $value === '') {
$result->setValue(false);
$result->addMessage('required');
}
if (is_array($value) && count($value) == 0) {
$result->setValue(false);
$result->addMessage('required');
}
return $result;
}
示例2: isValid
public function isValid($value)
{
$result = new Result(['value' => true]);
foreach ($this->validators as $validator) {
if ($result && method_exists($validator, 'getSkipOnPass') && $validator->getSkipOnPass()) {
continue;
}
if (!$result && method_exists($validator, 'getSkipOnFail') && $validator->getSkipOnFail()) {
continue;
}
$validatorResult = $validator->isValid($value);
if (!$validatorResult->getValue()) {
$result->setValue(false);
foreach ($validatorResult->getMessages() as $message) {
$result->addMessage($message);
}
if (method_exists($validator, 'getHaltOnFail') && $validator->getHaltOnFail()) {
return $result;
}
}
if (method_exists($validator, 'getHaltOnPass') && $validator->getHaltOnPass()) {
return $result;
}
}
return $result;
}
示例3: isValid
public function isValid($value)
{
$result = new Result(["value" => true]);
if (!$this->length->isValid($value)->getValue()) {
$result->setValue(false);
$result->addMessage('passwordLength');
}
if (!preg_match($this->containAlphaRegEx, $value)) {
$result->setValue(false);
$result->addMessage('passwordAlpha');
}
if (!preg_match($this->containNumRegEx, $value)) {
$result->setValue(false);
$result->addMessage('passwordNum');
}
return $result;
}
示例4: isValid
public function isValid($value)
{
$result = new Result(["value" => true]);
if (!preg_match($this->regex, $value)) {
$result->setValue(false);
$result->addMessage('alpha');
}
return $result;
}
示例5: isValid
public function isValid($value)
{
$result = new Result(["value" => true]);
if (!$value instanceof \DateTime) {
$result->setValue(false);
$result->addMessage('date');
}
return $result;
}
示例6: isValid
public function isValid($value)
{
$result = new Result(["value" => true]);
if (!preg_match('/^\\d{1,2}$/', $value['month']) || !preg_match('/^\\d\\d\\d\\d$/', $value['year'])) {
$result->setValue(false);
$result->addMessage('creditCardExpiry');
return $result;
}
$month = (int) $value['month'];
$year = (int) $value['year'];
$compareYear = date('Y');
$compareMonth = date('n');
if ($month < 1 || $month > 12 || $year < $compareYear || $year == $compareYear && $month < $compareMonth) {
$result->setValue(false);
$result->addMessage('creditCardExpiry');
}
return $result;
}
示例7: isValid
public function isValid($value)
{
$result = new Result(["value" => true]);
if (!($value < $this->compare)) {
$result->setValue(false);
$result->addMessage('lessThan');
}
return $result;
}
示例8: isValid
public function isValid($value)
{
$result = new Result(["value" => true]);
if (!($value === $this->compare && !$value instanceof \DateTime) && !($value instanceof \DateTime && $this->compare instanceof \DateTime && $value == $this->compare)) {
$result->setValue(false);
$result->addMessage('equal');
}
return $result;
}
示例9: isValid
public function isValid($value)
{
$result = new Result(["value" => true]);
if (!is_numeric($value)) {
$result->setValue(false);
$result->addMessage('float');
}
return $result;
}
示例10: isValid
public function isValid($value)
{
$result = new Result(["value" => true]);
if ($value !== true && $value !== false) {
$result->setValue(false);
$result->addMessage('boolean');
}
return $result;
}
示例11: isValid
public function isValid($value)
{
$result = new Result(["value" => true]);
if (!is_string($value)) {
$result->setValue(false);
$result->addMessage('string');
}
return $result;
}
示例12: isValid
public function isValid($value)
{
$result = new Result(["value" => true]);
if (!preg_match('/' . $this->regex . '/', $value)) {
$result->setValue(false);
$result->addMessage(['regex', $this->regex]);
}
return $result;
}
示例13: isValid
public function isValid($value)
{
$result = new Result(["value" => true]);
$length = strlen($value);
if ($length < $this->min || $length > $this->max) {
$result->setValue(false);
$result->addMessage(['length', $this->min, $this->max]);
}
return $result;
}
示例14: isValid
public function isValid($value)
{
$result = new Result(["value" => true]);
$value = preg_replace('/[- ]/', '', $value);
foreach ($this->cardInfo as $regex) {
if (preg_match('/^' . $regex . '$/', $value)) {
return $result;
}
}
$result->setValue(false);
$result->addMessage('creditCard');
return $result;
}