package org.apache.wicket.bean.validation;

import javax.validation.constraints.Size;

import org.apache.wicket.markup.ComponentTag;
import org.apache.wicket.markup.html.form.FormComponent;

/**
 * A tag modifier that adds the {@code maxlength} attribute to the {@code input} tag with the max
 * value from the {@link Size} constraint annotation.
 * 
 * @author igor
 * 
 */
public class SizeTagModifier implements ITagModifier<Size>
{
	@Override
	public void modify(FormComponent<?> component, ComponentTag tag, Size annotation)
	{
		if ("input".equalsIgnoreCase(tag.getName()))
		{
			tag.put("maxlength", annotation.max());
		}
	}
}

@@ -237,16 +237,39 @@
 xlength%7D
+ and  %7B@code minlength%7D
  attribu
@@ -270,16 +270,17 @@
 ttribute
+s
  to the 
@@ -292,16 +292,40 @@
 e input%7D
+%0A * and %7B@code textarea%7D
  tag wit
@@ -333,19 +333,20 @@
  the max
-%0A *
+/min
  value f
@@ -585,31 +585,25 @@
 if (
-%22input%22.equalsIgnoreCas
+hasLengthAttribut
 e(ta
@@ -667,11 +667,240 @@
 ));%0A
-%09%09%7D
+%0A%09%09%09if (annotation.min() %3E 0)%0A%09%09%09%7B%0A%09%09%09%09tag.put(%22minlength%22, annotation.min());%0A%09%09%09%7D%0A%09%09%7D%0A%09%7D%0A%0A%09protected boolean hasLengthAttribute(String tagName)%0A%09%7B%0A%09%09return %22input%22.equalsIgnoreCase(tagName) %7C%7C %22textarea%22.equalsIgnoreCase(tagName);
 %0A%09%7D%0A

Add 'minlength' to <input> or <textarea> if Size.min() is bigger than 0