Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FormValidator.validateSingleView() is not working as expected #44

Open
joomsite opened this issue Dec 30, 2016 · 1 comment
Open

FormValidator.validateSingleView() is not working as expected #44

joomsite opened this issue Dec 30, 2016 · 1 comment

Comments

@joomsite
Copy link

ValidationKomensky is fantastic Validator but there are 2 issues which put me off.

Issue 1 : FormValidator.validateSingleView() is not working as expected.

For Example,

I have following 3 validations on my form.

@notempty(messageId = R.string.validation_vehicle_registration,order = 1)
EditText vehicleNoEditText;

@notempty(messageId = R.string.validation_puc_number)
EditText pucNoEditText;

@DateInFuture(datePattern = "dd-MM-yyyy",allowToday = true, messageId = R.string.validation_date_in_future)
EditText pucEndDateEditText;

vehicleNoEditText is Mandatory but pucNoEditText & pucEndDateEditText are Non mandatory.

I want to validate pucNoEditText only if pucEndDateEditText is updated.

I implement this validation as below.

if(!FormValidator.validateSingleView(this, vehicleNoEditText, simpleCallback)){
isValid = false;
}

if(!StringUtils.isEmpty(pucEndDateEditText.getText().toString())){
if(FormValidator.validateSingleView(this, pucEndDateEditText, simpleCallback)){
isValid =false;
}
if(FormValidator.validateSingleView(this, pucNoEditText, simpleCallback)){
isValid =false;
}

}

Issue is FormValidator.validateSingleView(this, vehicleNoEditText, simpleCallback)- Not only validate vehicleNoEditText but all the validations declared in the Activities. This also validate pucNoEditText & pucEndDateEditText.( which I don't want to validate with vehicleNoEditText, I have separate validation call for them)

FormValidator.validateSingleView(Object target, View formContainer, View targetView, Map<view, fieldinfo=""> infoMap, IValidationCallback callback) - evaluate Single View then also validate all the other declared validations and returns false.
This is worse as no error shown against the others but I can't submit Form as well.

@Narayane
Copy link
Contributor

Narayane commented Mar 16, 2017

Hi @joomsite ,

I have made a pull request #46 to solve this issue :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants