public function term($value, string $pattern): array
    {
        $result = \preg_match("/$pattern/", $value);

        if ($result === false || $result === 0) {
            $errorCode = \preg_last_error();

            throw new \Exception("The pattern {$pattern} is not valid for value {$value}. Failed with error code {$errorCode}.");
        }

        return [
            'data' => [
                'generate' => $value,
                'matcher'  => [
                    'json_class' => 'Regexp',
                    'o'          => 0,
                    's'          => $pattern,
                ],
            ],
            'json_class' => 'Pact::Term',
        ];
    }
public function term($value, string $pattern): array
    {
        $result = \preg_match("/$pattern/", $value);

        if ($result === false || $result === 0) {
            $errorCode = \preg_last_error();

            throw new \Exception("The pattern {$pattern} is not valid for value {$value}. Failed with error code {$errorCode}.");
        }

        return [
            'data' => [
                'generate' => $value,
                'matcher'  => [
                    'json_class' => 'Regexp',
                    'o'          => 0,
                    's'          => $pattern,
                ],
            ],
            'json_class' => 'Pact::Term',
        ];
    }
public function term ( $ value , string $ pattern ) : array { $ result = \ preg_match ( "/$pattern/" , $ value ) ; if ( $ result === false || $ result === 0 ) { $ errorCode = \ preg_last_error ( ) ; throw new \ Exception ( "The pattern {$pattern} is not valid for value {$value}. Failed with error code {$errorCode}." ) ; } return [ 'data' => [ 'generate' => $ value , 'matcher' => [ 'json_class' => 'Regexp' , 'o' => 0 , 's' => $ pattern , ] , ] , 'json_class' => 'Pact::Term' , ] ; }
Validate that a value will match a regex pattern.

@param mixed  $value   example of what the expected data would be
@param string $pattern valid Ruby regex pattern

@throws \Exception

@return array
Validate that a value will match a regex pattern .