/** * @param $normalized_value * @throws \EE_Validation_Error */ public function validate($normalized_value) { $no_tags = wp_strip_all_tags($normalized_value); if (strlen($no_tags) < strlen(trim($normalized_value))) { throw new EE_Validation_Error($this->get_validation_error_message(), 'no_html_tags'); } parent::validate($normalized_value); }
/** * @param $normalized_value * @throws \EE_Validation_Error */ public function validate($normalized_value) { global $allowedposttags; parent::validate($normalized_value); $normalized_value_sans_tags = wp_kses("{$normalized_value}", $allowedposttags); if (strlen($normalized_value) > strlen($normalized_value_sans_tags)) { throw new EE_Validation_Error($this->get_validation_error_message(), 'complex_html_tags'); } }
/** * Check that the value is in the allowed list * @param $normalized_value * @throws EE_Error * @throws EE_Validation_Error * @return boolean */ function validate($normalized_value) { parent::validate($normalized_value); if (!$this->_input instanceof EE_Form_Input_With_Options_Base) { throw new EE_Error(sprintf(__("Cannot use Enum Validation Strategy with an input that doesn't have options", "event_espresso"))); } $enum_options = $this->_input->flat_options(); if ($normalized_value === TRUE) { $normalized_value = 1; } elseif ($normalized_value === FALSE) { $normalized_value = 0; } if ($normalized_value !== NULL && !array_key_exists($normalized_value, $enum_options)) { throw new EE_Validation_Error($this->get_validation_error_message(), 'invalid_enum_value'); } else { return true; } }
function test_validate__pass() { $this->_validator->validate('just some text; no html anywhere'); }