You are here

function patterns_validate_pattern in Patterns 7.2

Same name and namespace in other branches
  1. 6.2 patterns.module \patterns_validate_pattern()
  2. 6 patterns.module \patterns_validate_pattern()
  3. 7 includes/parser/parser.inc \patterns_validate_pattern()

Check if pattern array or content from a file is valid.

Parameters

mixed $pattern Pattern array or content of a pattern file.:

mixed $format The format of the file to validate against.:

integer $level Optional. The level of validation required.:

Return value

bool TRUE if valid, FALSE otherwise.

3 calls to patterns_validate_pattern()
patterns_db_save_pattern in includes/db.inc
Writes the pattern metadata (and the actual pattern) to the database.
patterns_io_scan_directories in includes/io/io.inc
Scan directories looking for patterns files.
_patterns_io_save_pattern in includes/io/io.inc
Lower level primitive for patterns_io_save_pattern. Includes an optional argument to force the UUUID

File

includes/parser/parser.inc, line 274

Code

function patterns_validate_pattern($pattern, $format = PATTERNS_FORMAT_UNKNOWN, $level = PATTERNS_VALIDATE_ALL) {
  if ($level == PATTERNS_VALIDATE_SKIP) {
    return TRUE;
  }
  $pattern = patterns_parser_parse($pattern, $format);
  if (!$pattern) {
    return FALSE;
  }
  if ($level == PATTERNS_VALIDATE_FORMAT) {
    return TRUE;
  }
  $scan = patterns_scan_pattern($pattern, FALSE, $level);
  return _patterns_scan_validate_patternscan($scan, FALSE, $level);
}