public function validate() { if (!v::num($this->result())) { return false; } if ($this->min and !v::min($this->result(), $this->min)) { return false; } if ($this->max and !v::max($this->result(), $this->max)) { return false; } return true; }
public function createNum($to = null) { $parent = $this->parent(); $params = $parent->blueprint()->pages()->num(); switch ($params->mode()) { case 'zero': return 0; break; case 'date': if ($to = $this->date($params->format(), $params->field())) { return $to; } else { return date($params->format()); } break; default: $visibleSiblings = $parent->children()->visible(); if ($to == 'last') { $to = $visibleSiblings->count() + 1; } else { if ($to == 'first') { $to = 1; } else { if (is_null($to)) { $to = $this->num(); } } } if (!v::num($to)) { return false; } if ($to <= 0) { return 1; } if ($this->isInvisible()) { $limit = $visibleSiblings->count() + 1; } else { $limit = $visibleSiblings->count(); } if ($limit < $to) { $to = $limit; } return intval($to); break; } }
public function validate() { if (!v::num($this->result())) { return false; } if ($this->validate and is_array($this->validate)) { return parent::validate(); } else { if ($this->min and !v::min($this->result(), $this->min)) { return false; } if ($this->max and !v::max($this->result(), $this->max)) { return false; } } return true; }
public function num($uid, $to = null) { $page = $this->find($uid); $blueprint = blueprint::find($this->parent); $params = $blueprint->pages()->num(); if ($to == 'last') { $to = $this->visible()->count() + 1; } switch ($params->mode()) { case 'zero': return 0; break; case 'date': if ($to = $page->date($params->format(), $params->field())) { return $to; } else { return date($params->format()); } break; default: if (v::num($to)) { if ($to <= 0) { $to = 1; } else { if ($page->isInvisible()) { $limit = $this->visible()->count() + 1; } else { $limit = $this->visible()->count(); } if ($limit < $to) { $to = $limit; } } return intval($to); } else { return false; } break; } }
public function testNum() { $this->assertTrue(v::num('1234')); $this->assertFalse(v::num('abc')); }
public function validate() { return v::num($this->result()); }