Added minlength/maxlength
authorMarcel Werk <burntime@woltlab.com>
Tue, 19 Feb 2013 23:07:33 +0000 (00:07 +0100)
committerMarcel Werk <burntime@woltlab.com>
Tue, 19 Feb 2013 23:07:33 +0000 (00:07 +0100)
wcfsetup/install/files/lib/system/option/TextOptionType.class.php
wcfsetup/install/lang/de.xml

index 3094464bffd1ef1b9c02c8caa14ff5cb9ecd5ff9..faff47c82f611cddd6625d81901fba7268a5b714 100644 (file)
@@ -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');
+               }
+       }
 }
index dc5031263cf17784be3e9d91361d01423d645f81..ed08fc68384dfce779b5be3f69fefd60e1899d80 100644 (file)
                <item name="wcf.user.username.error.notValid"><![CDATA[Sie haben einen ungültigen Benutzernamen eingegeben.]]></item>
                <item name="wcf.user.userNote"><![CDATA[{$__wcf->user->username}]]></item>
                <item name="wcf.user.group"><![CDATA[Benutzergruppe]]></item>
+               <item name="wcf.user.option.error.tooLong"><![CDATA[Der eingegebene Text ist zu lang.]]></item>
+               <item name="wcf.user.option.error.tooShort"><![CDATA[Der eingegebene Text ist zu kurz.]]></item>
+               <item name="wcf.user.option.error.validationFailed"><![CDATA[Sie haben einen ungültigen Inhalt eingegeben.]]></item>
        </category>
 </language>