68 $this->SecurityParser =
get_package(
'security::security_parser' ,
'last' , __FILE__ );
69 $this->String =
get_package(
'string' ,
'last' , __FILE__ );
70 $this->SupportedDataTypes =
get_package(
'security::supported_data_types' ,
'last' , __FILE__ );
100 private function dispatch_error_message( $Predicates )
104 foreach( $Predicates as $p )
106 if( strpos( $p ,
'err_msg_' ) === 0 )
108 return( str_replace(
'err_msg_' ,
'' , $p ) );
113 catch( Exception $e )
153 $Value =
get_field( $Data , $Name ,
'' );
155 if( $Value ==
'' && $this->SecurityParser->allow_not_set( $Predicates ) )
160 if( $Value ==
'' || $this->SupportedDataTypes->compile_data( $Value ,
'email' ) != $Value )
162 $this->ErrorMessage = $this->dispatch_error_message( $Predicates );
168 catch( Exception $e )
208 $Value =
get_field( $Data , $Name ,
'' );
210 if( $Value ===
'' && $this->SecurityParser->allow_not_set( $Predicates ) )
215 if( $Value ===
'' || $this->SupportedDataTypes->compile_data( $Value ,
'float' ) != $Value )
217 $this->ErrorMessage = $this->dispatch_error_message( $Predicates );
223 catch( Exception $e )
263 $Value =
get_field( $Data , $Name ,
'' );
265 if( $Value ===
'' && $this->SecurityParser->allow_not_set( $Predicates ) )
270 if( $Value ===
'' || $this->SupportedDataTypes->compile_data( $Value ,
'integer' ) != $Value )
272 $this->ErrorMessage = $this->dispatch_error_message( $Predicates );
278 catch( Exception $e )
318 $Value =
get_field( $Data , $Name ,
'' );
320 if( $Value ==
'' && $this->SecurityParser->allow_not_set( $Predicates ) === false )
322 $this->ErrorMessage = $this->dispatch_error_message( $Predicates );
328 catch( Exception $e )
368 $Value =
get_field( $Data , $Name ,
'' );
370 if( $Value ==
'' && $this->SecurityParser->allow_not_set( $Predicates ) )
375 if( $this->SupportedDataTypes->compile_data( $Value ,
'command' ) != $Value )
377 $this->ErrorMessage = $this->dispatch_error_message( $Predicates );
383 catch( Exception $e )
423 if( isset( $Data[ $Name ] ) ===
false )
425 $this->ErrorMessage = $this->dispatch_error_message( $Predicates );
431 catch( Exception $e )
471 if( isset( $Data[ $Name ] ) ===
true )
473 $this->ErrorMessage = $this->dispatch_error_message( $Predicates );
479 catch( Exception $e )
519 $Value =
get_field( $Data , $Name ,
'' );
522 $this->ErrorMessage = $this->dispatch_error_message( $Predicates );
528 catch( Exception $e )
564 private function exec_set( $Data , $Name , $Predicates )
568 if( isset( $Data[ $Name ] ) ===
false )
570 $this->ErrorMessage = $this->dispatch_error_message( $Predicates );
577 catch( Exception $e )
621 $Value = str_replace(
'value_' ,
'' , $Predicates[ $j ] );
623 if( $this->SupportedDataTypes->compile_data( @$Data[ $Name ] ,
'raw' ) != $Value )
625 $this->ErrorMessage = $this->dispatch_error_message( $Predicates );
632 catch( Exception $e )
672 function exec_min( $Data , $Name , $Predicates , $j )
676 $Value = intval( str_replace(
'min_' ,
'' , $Predicates[ $j ] ) );
678 if( $this->SupportedDataTypes->compile_data( $Data[ $Name ] ,
'raw' ) < $Value )
680 $this->ErrorMessage = $this->dispatch_error_message( $Predicates );
687 catch( Exception $e )
727 function exec_max( $Data , $Name , $Predicates , $j )
731 $Value = intval( str_replace(
'max_' ,
'' , $Predicates[ $j ] ) );
733 if( $this->SupportedDataTypes->compile_data( $Data[ $Name ] ,
'raw' ) > $Value )
735 $this->ErrorMessage = $this->dispatch_error_message( $Predicates );
742 catch( Exception $e )
786 $SecondField = str_replace(
'same_as_' ,
'' , $Predicates[ $j ] );
788 $SecondValue = $this->SupportedDataTypes->compile_data( $Data[ $SecondField ] ,
'raw' );
790 $First = $this->SupportedDataTypes->compile_data( $Data[ $Name ] ,
'raw' );
791 $Second = $this->SupportedDataTypes->compile_data( $SecondValue ,
'raw' );
793 if( $First !== $Second )
795 $this->ErrorMessage = $this->dispatch_error_message( $Predicates );
802 catch( Exception $e )
846 if( $Predicates[ $j ] ===
'set' )
848 return( $this->exec_set( $Data , $Name , $Predicates ) );
850 if( strpos( $Predicates[ $j ] ,
'err_msg_' ) === 0 )
854 if( strpos( $Predicates[ $j ] ,
'default_' ) !==
false )
859 throw(
new Exception(
"Undefined predicate '".$Predicates[ $j ].
"'" ) );
861 catch( Exception $e )