Giter Site home page Giter Site logo

android-validator's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

android-validator's Issues

Validator

Hello, I recently downloaded the library, and using it I found that the validation is sequential, so if I have 6 fields and 5 are erroneous but the latter is correct, then the validation will return true.

I took the liberty to fix the error I leave the code:

Class Form:

public boolean validate(){
    boolean result = true;
    int validator = 0;
    Iterator<AbstractValidate> it = this._validates.iterator();
    while(it.hasNext()){
        AbstractValidate validate = it.next();
        result = validate.isValid();
        if (result == false){
            validator++;
        }
    }
    if (validator > 0){
        result = false;
    }
    return result;
}

Thank you very much,
Andres Bocanumenth

Potential Memory Leak

Great library for easy form validation in Android, but I have a concern about potential memory leak in AbstractValidator class.

    protected Context mContext;

    public AbstractValidator(Context c) {
        mContext = c;
    }

I found out that this Context reference, if instantiated inside a Fragment that setRetainInstance == true, well retain a reference to the first activity passed in constructor.

AFAIK, according to Android Activity lifecycle, when there's configuration change, e.g when user change display orientation, an Activity will be destroyed and recreated. But a setRetainInstance == true fragment, will not be recreated on a configuration change.

So, in the end of Activity recreation, my retained fragment still hold a reference to the previously 'destroyed' Activity context, which is certainly a memory leak. CMIIW

I would like to contribute in this library, planning to have a pull request of my suggested implementation within this week :)

Z-index?

In the program that I'm coding, I have a sliding layer. When the validator checks and sees that the form isnt complete, it shows the error.

My problem is that the error pops up over the sliding layer when i slide it from the side but the textview is still under it under it.

Is there a way i can change the z index of it?

Failed resolution of: Lcom/throrinstudio/android/example/validator/R$string;

When I create an instance of any type of Validator, for example, NotEmptyValidator, there always be an error with detailedMessage "Failed resolution of: Lcom/throrinstudio/android/example/validator/R$string;".

My source code is following:
NotEmptyValidator notEmptyValidator = new NotEmptyValidator(fragment.getContext());

And the cause info of this error is:
java.lang.ClassNotFoundException: Didn't find class "com.throrinstudio.android.example.validator.R$string" on path: DexPathList[[zip file "/data/app/com.fourthdimension.gaodingv1android-2/base.apk"],nativeLibraryDirectories=[/vendor/lib64, /system/lib64]]

Add validation to disabled field

Wanted to know if we can add validation to disabled field. For example an EditText which is filled by output of DatePicker dialog. The DatePicker is enabled on tap of a button.

Other validatable objects?

....the form can just handle the EditText.

Just wondering what other objects did you want to validate. I wanted to try coding it

Message display and Translation issue

Hi,

First of all, thanks for your great jobs.

It's works great as an Android project.
But, I have a problem when I want to use it as a library. Form displays error bubbles (at the right place) but there is no text in bubbles.
I try with preset validator (NotEmptyValidator) with en-US, en-GB but still no message.

There is a screenshot of my app : http://goo.gl/Vu0fj

I put your string ressources in my main project but always the same problem.

Did you ever got this issue ? and managed it ?

closeAllErrors problem

function closeAllErrors() cant close ConfirmValidate. You'll get exception

E/AndroidRuntime(27795): java.lang.ClassCastException: >.validator.validate.ConfirmValidate cannot be cast to .validator.Validate

a (serious?) Bug in form validation

Hi,
I looked at the code for form validation and it looks like the following:

    /**
     * Called to validate our form.
     * If an error is found, it will be displayed in the corresponding field.
     *
     * @return boolean true if the form is valid, otherwise false
     */
    public boolean validate() {
        boolean formValid = true;
        for (AbstractValidate validate : mValidates) {
            // Form is invalid if only one of the validates is false (alternation rule)
            formValid = formValid || validate.isValid();
        }
        return formValid;
    }

since formValid = true from the start, it will always remain true, since
x = (true || false) = true
and
x = (true || true) = true.

So basically, the form always validates to true.
Am I missing something? :(

I think the OR should be replaced with AND...

Static Error Message in RangeValidator

Hi,

In the class "RangeValidator", there is a static class variable called "mErrorMessage".
It shouldn't be static as if you have multiple "RangeValidator", it will only keep the last value.

In my case i had 3 RangeValidator and the same message was displayed three times. Removing "static" modifier fix the issue.

Actually, i'm also wondering why "getMessage" is overrided in "RangeValidator" while it is not in others validators. :)

Regards,
Clément.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.