Coder Social home page Coder Social logo

z-validations's People

Contributors

bitdeli-chef avatar sirasistant avatar zasadnyy avatar

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

Watchers

 avatar  avatar  avatar  avatar  avatar

z-validations's Issues

FormUtils.hideKeyboard(Context,TextView) improvement

I ran into some trouble while using this function. The Problem is, that I have to keep the textView with the focus to use this method. Currently I'm using always the last TextView in my Form, but that is a dirty way. I found out, that it is possible to get the IBinder to the InputConnection via Activity.

http://stackoverflow.com/questions/7789514/how-to-get-activitys-windowtoken-without-view

so there Could be a new method signature like: hideKeyboard(Activity)

Best Regards
Max

New validation InRangeNotStrict

  • use Integer instead of int to allow null
  • InRangeNotStrict: checks if field value is integer and is in range min <= value <= max
  • if min is null then checks value <= max
  • if max is nullthen checks min <= value
package ua.org.zasadnyy.zvalidations.validations;

import android.content.Context;
import android.widget.EditText;
import ua.org.zasadnyy.zvalidations.Field;
import ua.org.zasadnyy.zvalidations.R;
import ua.org.zasadnyy.zvalidations.ValidationResult;

/**
 * Created by vitaliyzasadnyy on 04.08.13.
 */
public class InRangeNotStrict extends BaseValidation {

    private Integer mMin;
    private Integer mMax;

    private InRangeNotStrict(Context context, Integer min, Integer max) {
        super(context);
        mMin = min;
        mMax = max;
    }

    public static Validation build(Context context, Integer min, Integer max) {
        return new InRangeNotStrict(context, min, max);
    }

    @Override
    public ValidationResult validate(Field field) {
        EditText textView = field.getTextView();
        boolean isValid = false;
        try {
            int value = Integer.parseInt(textView.getText().toString());
            isValid = (mMin == null || value >= mMin) && (mMax == null || value <= mMax);
        } catch (NumberFormatException ignored) {
        }
        return isValid ?
                ValidationResult.buildSuccess(textView)
                : ValidationResult.buildFailed(textView, mContext.getString(
                mMin == null ?
                        R.string.zvalidations_not_in_range_max
                        : (mMax == null ?
                        R.string.zvalidations_not_in_range_min
                        : R.string.zvalidations_not_in_range
                ), mMin, mMax
        ));
    }
}
  • new resources
    <string name="zvalidations_not_in_range_min">Field should be greater or equal than %1$d</string>
    <string name="zvalidations_not_in_range_max">Field should be lower or equal than %2$d</string>

New Strings ? Also -> Images

Hi,

I just extended your nice library by a functionality to check for a length. E.g: The password has to be at least 8 characters. The problem I'm facing is the following.

ValidationResult.buildFailed(textView, mContext.getString(R.string.zvalidations_too_short, mMin));

The string : zvalidations_too_short - How exactly do I implement it? In my Eclipse src-folder I have 3 packages. 2 of you and 1 from me.
So how would I go to add new strings?

Also, when an error message comes, I'm getting no message. I'm getting a text that says
res/drawable-xhdpi/abs__ab_bottom_solid_light_holo.9.png

But I can't find where in Code you did that. If you can tell me where exactly I have to add the strings I could do a pull request. :) OR, I could just send you the source code of the class ( It's not really long, I think it's just helpful for people who don't really know how to make a new validation )

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.