public function createRule($name, $options = null, $messageTemplate = null, $label = null)
    {
        $validator = $this->construcRuleByNameAndOptions($name, $options);

        // no message template, try to get it from the registry
        if (!$messageTemplate) {
            $messageTemplate = $this->getSuggestedMessageTemplate($name, !!$label);
        }

        if (is_string($messageTemplate) && $messageTemplate !== '') {
            $validator->setMessageTemplate($messageTemplate);
        }
        if (is_string($label) && $label !== '') {
            $validator->setOption('label', $label);
        }

        return $validator;
    }
public function createRule($name, $options = null, $messageTemplate = null, $label = null)
    {
        $validator = $this->construcRuleByNameAndOptions($name, $options);

        // no message template, try to get it from the registry
        if (!$messageTemplate) {
            $messageTemplate = $this->getSuggestedMessageTemplate($name, !!$label);
        }

        if (is_string($messageTemplate) && $messageTemplate !== '') {
            $validator->setMessageTemplate($messageTemplate);
        }
        if (is_string($label) && $label !== '') {
            $validator->setOption('label', $label);
        }

        return $validator;
    }
public function createRule ( $ name , $ options = null , $ messageTemplate = null , $ label = null ) { $ validator = $ this -> construcRuleByNameAndOptions ( $ name , $ options ) ; // no message template, try to get it from the registry if ( ! $ messageTemplate ) { $ messageTemplate = $ this -> getSuggestedMessageTemplate ( $ name , ! ! $ label ) ; } if ( is_string ( $ messageTemplate ) && $ messageTemplate !== '' ) { $ validator -> setMessageTemplate ( $ messageTemplate ) ; } if ( is_string ( $ label ) && $ label !== '' ) { $ validator -> setOption ( 'label' , $ label ) ; } return $ validator ; }
Factory method to construct a validator based on options that are used most of the times

@param string|callable $name
name of a validator class or a callable object/function
@param string|array $options
validator options (an array, JSON string or QUERY string)
@param string $messageTemplate
error message template
@param string $label
label of the form input field or model attribute

@throws \InvalidArgumentException
@return \Sirius\Validation\Rule\AbstractValidator
Factory method to construct a validator based on options that are used most of the times