From: Marcel Werk Date: Tue, 19 Feb 2013 23:07:33 +0000 (+0100) Subject: Added minlength/maxlength X-Git-Tag: 2.0.0_Beta_1~463 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=8e5a1d4c070ab497f9c2176bf9d320c7dd0af5dc;p=GitHub%2FWoltLab%2FWCF.git Added minlength/maxlength --- diff --git a/wcfsetup/install/files/lib/system/option/TextOptionType.class.php b/wcfsetup/install/files/lib/system/option/TextOptionType.class.php index 3094464bff..faff47c82f 100644 --- a/wcfsetup/install/files/lib/system/option/TextOptionType.class.php +++ b/wcfsetup/install/files/lib/system/option/TextOptionType.class.php @@ -2,6 +2,7 @@ namespace wcf\system\option; use wcf\data\option\Option; use wcf\system\database\util\PreparedStatementConditionBuilder; +use wcf\system\exception\UserInputException; use wcf\system\WCF; use wcf\util\StringUtil; @@ -58,4 +59,16 @@ class TextOptionType extends AbstractOptionType implements ISearchableUserOption $conditions->add("option_value.userOption".$option->optionID." LIKE ?", array('%'.addcslashes($value, '_%').'%')); return true; } + + /** + * @see wcf\system\option\IOptionType::validate() + */ + public function validate(Option $option, $newValue) { + if ($option->minlength !== null && $option->minlength > StringUtil::length($newValue)) { + throw new UserInputException($option->optionName, 'tooShort'); + } + if ($option->maxlength !== null && $option->maxlength < StringUtil::length($newValue)) { + throw new UserInputException($option->optionName, 'tooLong'); + } + } } diff --git a/wcfsetup/install/lang/de.xml b/wcfsetup/install/lang/de.xml index dc5031263c..ed08fc6838 100644 --- a/wcfsetup/install/lang/de.xml +++ b/wcfsetup/install/lang/de.xml @@ -1003,5 +1003,8 @@ user->username}]]> + + +