// Path: GGAForms/ggaforms/src/main/java/com/greengrowapps/ggaforms/fields/FormInput.java
// public interface FormInput<T> {
// 
//     void setOnInputChangedListener(OnInputChangedListener listener);
// 
//     void setError(ValidationError error);
// 
//     Class<T> getType();
//     T getValue();
//     void setValue(T value);
// 
//     ValidationError getError();
// }
// 
// Path: GGAForms/ggaforms/src/main/java/com/greengrowapps/ggaforms/validation/errors/ErrorBuilder.java
// public interface ErrorBuilder {
//     ValidationError build( Object ... params );
// }
// 
// Path: GGAForms/ggaforms/src/main/java/com/greengrowapps/ggaforms/validation/errors/ValidationError.java
// public interface ValidationError {
//     CharSequence getLocalizedMessage();
// }


import com.greengrowapps.ggaforms.fields.FormInput;
import com.greengrowapps.ggaforms.validation.errors.ErrorBuilder;
import com.greengrowapps.ggaforms.validation.errors.ValidationError;
import java.util.regex.Pattern;
package com.greengrowapps.ggaforms.validation.validator;




public class RegexValidator extends BaseValidator {

    private final String regex;
    private final ErrorBuilder errorBuilder;

    public RegexValidator(FormInput input, ErrorBuilder errorBuilder, String regex) {
        super(input);
        this.regex = regex;
        this.errorBuilder = errorBuilder;
    }

    @Override
    protected boolean isValidValue(Object parent, Object value) {
        if(value instanceof CharSequence){
            String string = ((CharSequence)value).toString();
            return Pattern.matches(regex, string);
        }
        return false;
    }

    @Override
    protected ValidationError getValidationError(Object value) {
// Path: GGAForms/ggaforms/src/main/java/com/greengrowapps/ggaforms/fields/FormInput.java
// public interface FormInput<T> {
// 
//     void setOnInputChangedListener(OnInputChangedListener listener);
// 
//     void setError(ValidationError error);
// 
//     Class<T> getType();
//     T getValue();
//     void setValue(T value);
// 
//     ValidationError getError();
// }
// 
// Path: GGAForms/ggaforms/src/main/java/com/greengrowapps/ggaforms/validation/errors/ErrorBuilder.java
// public interface ErrorBuilder {
//     ValidationError build( Object ... params );
// }
// 
// Path: GGAForms/ggaforms/src/main/java/com/greengrowapps/ggaforms/validation/errors/ValidationError.java
// public interface ValidationError {
//     CharSequence getLocalizedMessage();
// }


// Path: GGAForms/ggaforms/src/main/java/com/greengrowapps/ggaforms/validation/validator/RegexValidator.java
import com.greengrowapps.ggaforms.fields.FormInput;
import com.greengrowapps.ggaforms.validation.errors.ErrorBuilder;
import com.greengrowapps.ggaforms.validation.errors.ValidationError;
import java.util.regex.Pattern;

package com.greengrowapps.ggaforms.validation.validator;




public class RegexValidator extends BaseValidator {

    private final String regex;
    private final ErrorBuilder errorBuilder;

    public RegexValidator(FormInput input, ErrorBuilder errorBuilder, String regex) {
        super(input);
        this.regex = regex;
        this.errorBuilder = errorBuilder;
    }

    @Override
    protected boolean isValidValue(Object parent, Object value) {
        if(value instanceof CharSequence){
            String string = ((CharSequence)value).toString();
            return Pattern.matches(regex, string);
        }
        return false;
    }

    @Override
    protected ValidationError getValidationError(Object value) {
        return errorBuilder.build();