public function validate($input) { if (!is_string($input)) { return false; } if (0 === mb_strpos($input, '#')) { $input = mb_substr($input, 1); } $length = mb_strlen($input); if ($length != 3 && $length != 6) { return false; } return parent::validate($input); }
/** * @dataProvider providerAdditionalChars */ public function testAdditionalCharsShouldBeRespected($additional, $query) { $validator = new Xdigit($additional); $this->assertTrue($validator->validate($query)); }
/** * @expectedException Respect\Validation\Exceptions\XdigitException */ public function testShortcutInvalidCheck() { $xdigits = new Xdigit(); $o = $xdigits->addOr(new Alnum()); $this->assertFalse($o->validate(-10)); $this->assertFalse($o->check(-10)); }