@copyright GPL v3 @version 20130524 **/ trait minlength { /** @brief Minimum allowed length of this input's string. @var $minlength @since 20130524 **/ public $minlength = null; /** @details It should be called min_length, but the attribute in html is without the underscore. @param int $minlength Minimum allowed length. @return this Object chaining. @since 20130524 **/ public function minlength( $minlength ) { $this->add_validation_method( 'minlength' ); $this->minlength = intval( $minlength ); return $this; } /** @details Checks that the input is of the set minimum length. @since 20130524 **/ public function validate_minlength() { if ( strlen( $this->validation_value ) < $this->minlength ) { $text = $this->form()->_( 'The text in %s is too short!', '' . $this->get_label()->content . '' ); $this->validation_error()->set_unfiltered_label_( $text ); } } }