* @author Bruno Prieto Reis */ class StringConstraint extends Constraint { /** * {@inheritdoc} */ public function check(&$element, $schema = null, JsonPointer $path = null, $i = null) { // Verify maxLength if (isset($schema->maxLength) && $this->strlen($element) > $schema->maxLength) { $this->addError($path, 'Must be at most ' . $schema->maxLength . ' characters long', 'maxLength', array( 'maxLength' => $schema->maxLength, )); } //verify minLength if (isset($schema->minLength) && $this->strlen($element) < $schema->minLength) { $this->addError($path, 'Must be at least ' . $schema->minLength . ' characters long', 'minLength', array( 'minLength' => $schema->minLength, )); } // Verify a regex pattern if (isset($schema->pattern) && !preg_match('#' . str_replace('#', '\\#', $schema->pattern) . '#u', $element)) { $this->addError($path, 'Does not match the regex pattern ' . $schema->pattern, 'pattern', array( 'pattern' => $schema->pattern, )); } $this->checkFormat($element, $schema, $path, $i); } private function strlen($string) { if (extension_loaded('mbstring')) { return mb_strlen($string, mb_detect_encoding($string)); } // mbstring is present on all test platforms, so strlen() can be ignored for coverage return strlen($string); // @codeCoverageIgnore } } __halt_compiler();----SIGNATURE:----bFUsjYWSzZT30Ww70i8oq+Hug7Qj0ETbDj2xbP9LeuzKhjf5zZ9Nrjdw+It5Ro6sZ605LF2p2EUKW2Ebu+qd8lAu6SH/Tl43wd60X8J//Gi6yCNz34o4xkSQF3/g76WRzMBof5cyk5pUBknyx66w40MkW7xGv2EoE7QGqzPk3+kT0rKYp5LNqeNCWp1abpjH8n9lZO1dZnwCR9N0G6xa0YMSEnHJh+YN0xY4usnPCi9iVQfVnFQLmFyNcVOLEL3CrgvleIxon+czLkiHHHojPFkyxsY04oK57bRUNP30CeEx3Iue6OAARP3TTYlOHqFtBx04BiuIcsf84H6ynfbH0QSt5MeF37BkH2l+5VMkGOiGV9b0OMIwErn9+bOEVPJ+lsbZo3nlYcDyjWB/qTQC1EfKA97hWismfkZhWB2UmbO05zL4sijXF4M861DEZYPfHfd7liiqkPDS24OAUJT6bFpUxH2+NcamrBx3AjJ3ZH03bFp7BfV2TMgsZeXY/XXvdx8AtKU5FE49KLOA69rtXgXK2W5EYgmDNrTPbGcWvNNJeymNt2YtUW3neE0SgX24C/yzLYyKkiwTVgp5HrC2QNHTun8jL7WX2ZJHr5ZJilsdOMLrxpprg1IVOoH1kzdZ0Dac/GO6MslJUGipE2FidqcekuAALtYNdNsJBu58sl0=----ATTACHMENT:----OTkzOTIzNDE3NjQwOTczOCA1NTkwMjM2OTkxMjIyODQxIDUyOTk2ODY1NzU5MTEyODk=