package br.com.bloder.blormlib.validation.validations;

import android.widget.EditText;

import br.com.bloder.blormlib.validation.Validate;
import br.com.bloder.blormlib.validation.Validation;

/**
 * Created by bloder on 05/06/16.
 */
public class Filled extends Validation {

  public EditText editText;

  @Override
  public Validate validate() {
    return new Validate() {
      @Override
      public boolean validate() {
        editText = (EditText) field;
        return !String.valueOf(editText.getText()).trim().isEmpty();
      }

      @Override
      public void onError() {
        editText.setError(errorMessage != null && !errorMessage.isEmpty() ? errorMessage : "This field can't be blank");
      }

      @Override public void onSuccess() {
        editText.setError(null);
      }
    };
  }
}

@@ -299,16 +299,264 @@
 itText;%0A
+  private int maxSize = -1;%0A  private int minSize = -1;%0A %0A  public Filled withMaxSize(int maxSize) %7B%0A    this.maxSize = maxSize;%0A    return this;%0A  %7D%0A %0A  public Filed withMinimumSize(int minSize) %7B%0A    this.minSize = minSize;%0A    return this;%0A  %7D%0A 
 %0A  @Over
@@ -559,18 +559,16 @@
 Override
-%0A 
  public 
@@ -624,38 +624,32 @@
 %0A      @Override
-%0A     
  public boolean 
@@ -710,16 +710,22 @@
     
-return !
+String text = 
 Stri
@@ -761,26 +761,392 @@
 ).trim()
-.isEmpty()
+;%0A        int textLength = text.length();%0A        if (!text.isEmpty()) %7B%0A          if (maxSize != -1) %7B%0A            if (textLength %3E maxSize) %7B%0A              return false;%0A            %7D%0A          %7D%0A          if (minSize != -1) %7B%0A            if (textLength %3C minSize) %7B%0A              return false;%0A            %7D%0A          %7D%0A          return true;%0A        %7D%0A        return false
 ;%0A      

Update with min max for text input validation