zasadnyy / z-validations Goto Github PK
View Code? Open in Web Editor NEWMake your Android form validations easy
License: MIT License
Make your Android form validations easy
License: MIT License
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
Is posible to have a jar in the releases projects for not gradle users?
Maybe is better to use Context
public Form(Context context) {
...
}
Hello
I have this Custom EditText and I wanted to add the validation
mForm.addField(Field.using(mFloatLabelEditText).validate(NotEmpty.build(getActivity())));
Integer
instead of int
to allow null
min <= value <= max
null
then checks value <= max
null
then 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
));
}
}
<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>
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 )
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.