package br.com.bloder.blormlib;

import android.content.Context;
import android.view.View;
import android.widget.Toast;

import java.util.ArrayList;
import java.util.List;

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

/**
 * Created by bloder on 05/06/16.
 */
public class Blorm {

  public static class Builder {

    private List<Validate> validations;
    private View field;

    public Builder() {
      validations = new ArrayList<>();
    }

    public Builder field(View field) {
      this.field = field;
      return this;
    }

    public Builder is(Validate validation) {
      this.validations.add(validation);
      return this;
    }

    public Builder is(Validation validation) {
      validation.field = this.field;
      this.validations.add(validation.validate());
      return this;
    }

    public void onSubmit(View submittedItem) {
      new Blorm(this.validations).onSubmitted();
    }
  }

  private List<Validate> validations;
  
  public Blorm(List<Validate> validations) {
    this.validations = validations;
  }

  private void onSubmitted() {
    for(Validate validate : validations) {
      if(validate.validate()) {
      } else {
      }
    }
  }
}

@@ -45,78 +45,17 @@
 oid.
-content.Context;%0Aimport android.view.View;%0Aimport android.widget.Toast
+view.View
 ;%0A%0Ai
@@ -796,32 +796,260 @@
 rn this;%0A    %7D%0A%0A
+    public Builder is(String errorMessgae, Validation validation) %7B%0A      validation.field = this.field;%0A      validation.errorMessage = errorMessgae;%0A      this.validations.add(validation.validate());%0A      return this;%0A    %7D%0A%0A
     public void 
@@ -1349,16 +1349,17 @@
      if(
+!
 validate
@@ -1383,16 +1383,29 @@
     
-%7D else %7B
+  validate.onError();
 %0A   

Add is function with error message in blorm class