21 private $validationRegex;
24 parent::__construct( $params );
26 if ( is_string( $params ) ) {
27 $this->validationRegex = $params;
28 } elseif ( is_array( $params ) ) {
29 $this->validationRegex = $params[
'regex'] ??
null;
32 if ( $this->validationRegex ===
null ) {
33 throw new InvalidArgumentException(
'The configuration for InsertableRegexValidator does not ' .
34 'specify a regular expression.' );
41 preg_match_all( $this->validationRegex, $message->
definition(), $definitionMatch );
42 preg_match_all( $this->validationRegex, $message->
translation(), $translationMatch );
43 $definitionVariables = $definitionMatch[0];
44 $translationVariables = $translationMatch[0];
46 $missingVariables = array_diff( $definitionVariables, $translationVariables );
47 if ( $missingVariables ) {
51 'translate-checks-parameters',
53 [
'PLAIN-PARAMS', $missingVariables ],
54 [
'COUNT', count( $missingVariables ) ]
58 $issues->add( $issue );
61 $unknownVariables = array_diff( $translationVariables, $definitionVariables );
62 if ( $unknownVariables ) {
66 'translate-checks-parameters-unknown',
68 [
'PLAIN-PARAMS', $unknownVariables ],
69 [
'COUNT', count( $unknownVariables ) ]
73 $issues->add( $issue );