ilhasoft / data-binding-validator Goto Github PK
View Code? Open in Web Editor NEWAndroid fields validation library based on data binding adapters.
License: Apache License 2.0
Android fields validation library based on data binding adapters.
License: Apache License 2.0
Here is the stacktrace for the same.
/Users/patty/project-inspiration-dir/StaffingEmployee/app/build/generated/source/kapt/prodDebug/com/aasaanjobs/dashboard/databinding/FragmentIssueBinding.java:126: error: package br.com.ilhasoft.support.validation.binding does not exist
br.com.ilhasoft.support.validation.binding.TypeBindings.bindingTypeValidation(this.mboundView1, "email", (java.lang.String)null, (boolean)false);
^
1 errorFAILED
FAILURE: Build failed with an exception.
- What went wrong:
Execution failed for task ':app:compileProdDebugJavaWithJavac'.Compilation failed; see the compiler error output for details.
Try:
Run with --info or --debug option to get more log output. Run with --scan to get full insights.Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:compileProdDebugJavaWithJavac'.
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:103)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:73)
at org.gradle.api.internal.tasks.execution.OutputDirectoryCreatingTaskExecuter.execute(OutputDirectoryCreatingTaskExecuter.java:51)
at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:59)
at org.gradle.api.internal.tasks.execution.ResolveTaskOutputCachingStateExecuter.execute(ResolveTaskOutputCachingStateExecuter.java:54)
at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:59)
at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:101)
at org.gradle.api.internal.tasks.execution.FinalizeInputFilePropertiesTaskExecuter.execute(FinalizeInputFilePropertiesTaskExecuter.java:44)
at org.gradle.api.internal.tasks.execution.CleanupStaleOutputsExecuter.execute(CleanupStaleOutputsExecuter.java:88)
at org.gradle.api.internal.tasks.execution.ResolveTaskArtifactStateTaskExecuter.execute(ResolveTaskArtifactStateTaskExecuter.java:62)
at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52)
at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:54)
at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:34)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker$1.run(DefaultTaskGraphExecuter.java:248)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:199)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:110)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:241)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:230)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.processTask(DefaultTaskPlanExecutor.java:123)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.access$200(DefaultTaskPlanExecutor.java:79)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:104)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:98)
at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.execute(DefaultTaskExecutionPlan.java:623)
at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.executeWithTask(DefaultTaskExecutionPlan.java:578)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.run(DefaultTaskPlanExecutor.java:98)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor.process(DefaultTaskPlanExecutor.java:59)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter.execute(DefaultTaskGraphExecuter.java:128)
at org.gradle.execution.SelectedTaskExecutionAction.execute(SelectedTaskExecutionAction.java:37)
at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:37)
at org.gradle.execution.DefaultBuildExecuter.access$000(DefaultBuildExecuter.java:23)
at org.gradle.execution.DefaultBuildExecuter$1.proceed(DefaultBuildExecuter.java:43)
at org.gradle.execution.DryRunBuildExecutionAction.execute(DryRunBuildExecutionAction.java:46)
at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:37)
at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:30)
at org.gradle.initialization.DefaultGradleLauncher$ExecuteTasks.run(DefaultGradleLauncher.java:318)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:199)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:110)
at org.gradle.initialization.DefaultGradleLauncher.runTasks(DefaultGradleLauncher.java:204)
at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:134)
at org.gradle.initialization.DefaultGradleLauncher.executeTasks(DefaultGradleLauncher.java:109)
at org.gradle.internal.invocation.GradleBuildController$1.call(GradleBuildController.java:78)
at org.gradle.internal.invocation.GradleBuildController$1.call(GradleBuildController.java:75)
at org.gradle.internal.work.DefaultWorkerLeaseService.withLocks(DefaultWorkerLeaseService.java:152)
at org.gradle.internal.invocation.GradleBuildController.doBuild(GradleBuildController.java:100)
at org.gradle.internal.invocation.GradleBuildController.run(GradleBuildController.java:75)
at org.gradle.tooling.internal.provider.runner.ClientProvidedBuildActionRunner.run(ClientProvidedBuildActionRunner.java:62)
at org.gradle.launcher.exec.ChainingBuildActionRunner.run(ChainingBuildActionRunner.java:35)
at org.gradle.launcher.exec.ChainingBuildActionRunner.run(ChainingBuildActionRunner.java:35)
at org.gradle.tooling.internal.provider.ValidatingBuildActionRunner.run(ValidatingBuildActionRunner.java:32)
at org.gradle.launcher.exec.RunAsBuildOperationBuildActionRunner$1.run(RunAsBuildOperationBuildActionRunner.java:43)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:199)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:110)
at org.gradle.launcher.exec.RunAsBuildOperationBuildActionRunner.run(RunAsBuildOperationBuildActionRunner.java:40)
at org.gradle.tooling.internal.provider.SubscribableBuildActionRunner.run(SubscribableBuildActionRunner.java:51)
at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:49)
at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:32)
at org.gradle.launcher.exec.BuildTreeScopeBuildActionExecuter.execute(BuildTreeScopeBuildActionExecuter.java:39)
at org.gradle.launcher.exec.BuildTreeScopeBuildActionExecuter.execute(BuildTreeScopeBuildActionExecuter.java:25)
at org.gradle.tooling.internal.provider.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:80)
at org.gradle.tooling.internal.provider.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:53)
at org.gradle.tooling.internal.provider.ServicesSetupBuildActionExecuter.execute(ServicesSetupBuildActionExecuter.java:57)
at org.gradle.tooling.internal.provider.ServicesSetupBuildActionExecuter.execute(ServicesSetupBuildActionExecuter.java:32)
at org.gradle.tooling.internal.provider.GradleThreadBuildActionExecuter.execute(GradleThreadBuildActionExecuter.java:36)
at org.gradle.tooling.internal.provider.GradleThreadBuildActionExecuter.execute(GradleThreadBuildActionExecuter.java:25)
at org.gradle.tooling.internal.provider.ParallelismConfigurationBuildActionExecuter.execute(ParallelismConfigurationBuildActionExecuter.java:43)
at org.gradle.tooling.internal.provider.ParallelismConfigurationBuildActionExecuter.execute(ParallelismConfigurationBuildActionExecuter.java:29)
at org.gradle.tooling.internal.provider.StartParamsValidatingActionExecuter.execute(StartParamsValidatingActionExecuter.java:64)
at org.gradle.tooling.internal.provider.StartParamsValidatingActionExecuter.execute(StartParamsValidatingActionExecuter.java:29)
at org.gradle.tooling.internal.provider.SessionFailureReportingActionExecuter.execute(SessionFailureReportingActionExecuter.java:59)
at org.gradle.tooling.internal.provider.SessionFailureReportingActionExecuter.execute(SessionFailureReportingActionExecuter.java:44)
at org.gradle.tooling.internal.provider.SetupLoggingActionExecuter.execute(SetupLoggingActionExecuter.java:45)
at org.gradle.tooling.internal.provider.SetupLoggingActionExecuter.execute(SetupLoggingActionExecuter.java:30)
at org.gradle.launcher.daemon.server.exec.ExecuteBuild.doBuild(ExecuteBuild.java:67)
at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36)
at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:122)
at org.gradle.launcher.daemon.server.exec.WatchForDisconnection.execute(WatchForDisconnection.java:37)
at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:122)
at org.gradle.launcher.daemon.server.exec.ResetDeprecationLogger.execute(ResetDeprecationLogger.java:26)
at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:122)
at org.gradle.launcher.daemon.server.exec.RequestStopIfSingleUsedDaemon.execute(RequestStopIfSingleUsedDaemon.java:34)
at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:122)
at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(ForwardClientInput.java:74)
at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(ForwardClientInput.java:72)
at org.gradle.util.Swapper.swap(Swapper.java:38)
at org.gradle.launcher.daemon.server.exec.ForwardClientInput.execute(ForwardClientInput.java:72)
at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:122)
at org.gradle.launcher.daemon.server.exec.LogAndCheckHealth.execute(LogAndCheckHealth.java:55)
at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:122)
at org.gradle.launcher.daemon.server.exec.LogToClient.doBuild(LogToClient.java:62)
at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36)
at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:122)
at org.gradle.launcher.daemon.server.exec.EstablishBuildEnvironment.doBuild(EstablishBuildEnvironment.java:82)
at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36)
at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:122)
at org.gradle.launcher.daemon.server.exec.StartBuildOrRespondWithBusy$1.run(StartBuildOrRespondWithBusy.java:50)
at org.gradle.launcher.daemon.server.DaemonStateCoordinator$1.run(DaemonStateCoordinator.java:295)
at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46)
at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
Caused by: org.gradle.api.internal.tasks.compile.CompilationFailedException: Compilation failed; see the compiler error output for details.
at org.gradle.api.internal.tasks.compile.JdkJavaCompiler.execute(JdkJavaCompiler.java:50)
at org.gradle.api.internal.tasks.compile.JdkJavaCompiler.execute(JdkJavaCompiler.java:35)
at org.gradle.api.internal.tasks.compile.NormalizingJavaCompiler.delegateAndHandleErrors(NormalizingJavaCompiler.java:98)
at org.gradle.api.internal.tasks.compile.NormalizingJavaCompiler.execute(NormalizingJavaCompiler.java:51)
at org.gradle.api.internal.tasks.compile.NormalizingJavaCompiler.execute(NormalizingJavaCompiler.java:37)
at org.gradle.api.internal.tasks.compile.CleaningJavaCompilerSupport.execute(CleaningJavaCompilerSupport.java:35)
at org.gradle.api.internal.tasks.compile.CleaningJavaCompilerSupport.execute(CleaningJavaCompilerSupport.java:25)
at org.gradle.api.tasks.compile.JavaCompile.performCompilation(JavaCompile.java:207)
at org.gradle.api.tasks.compile.JavaCompile.compile(JavaCompile.java:192)
at org.gradle.api.tasks.compile.JavaCompile.compile(JavaCompile.java:124)
at com.android.build.gradle.tasks.factory.AndroidJavaCompile.compile(AndroidJavaCompile.java:95)
at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:73)
at org.gradle.api.internal.project.taskfactory.IncrementalTaskAction.doExecute(IncrementalTaskAction.java:50)
at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:39)
at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:26)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$1.run(ExecuteActionsTaskExecuter.java:124)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:199)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:110)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:113)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:95)
... 105 more
I'm getting this error while upgrade to verison 2.0.0 Caused by: org.gradle.tooling.BuildException: Failed to process resources, see aapt output above for details.
but when I downgrade to version 1.0.0 everythings is OK, but in CI i'm getting error pipeline
Could not find com.github.Ilhasoft:data-binding-validator:1.0.0.
because version 1.0.0 getting fail in jitpack.
this is my setup
classpath 'com.android.tools.build:gradle:3.1.3'
maven { url 'https://jitpack.io' }
Spaces only in a field pass validateEmpty rule so there should also be a new validateBlank rule that can be applied on a field if spaces only are not allowed. Let me know if you want me to make a PR for the same.
Hi,
I'm new to Android Studio and I'm having some trouble with the data binding. I did all the steps on the ReadMe file and still can't make it work.
Corretc me if I'm wrong, but I need to add this to my layout right?
<layout xmlns:android="http://schemas.android.com/apk/res/android"> <data> <variable name="androidvalidation" type="com.github.Ilhasoft:data-binding-validator:0.6.1"/> </data> </layout>
So then I can use the app:validateMinLength="@{4}"
.
Thank you!
Hey there, I found that a same issue has been raised before and he only forgot to add the maven repository link.
I have them both
maven { url 'https://jitpack.io' }
maven { url 'https://maven.fabric.io/public' }
Well the problem is I have 2 maven repository.
May I know where do you think the problem is here's my implementation
repositories {
google()
jcenter()
mavenCentral()
maven { url 'https://jitpack.io' }
maven { url 'https://maven.fabric.io/public' }
}
and
implementation 'com.github.Ilhasoft:data-binding-validator:1.0.0'
Cheers!
If we implement a ValidationListener, it would be nice to get the error message in the onValidationError. Otherwise, how do we know which rule failed?
NOTE: This is due to a product requirement to change the UI of the error message.
How can I validate a Spinner? I tried adding one of the validations but I get this compilation error:
Cannot find a setter for <androidx.appcompat.widget.AppCompatSpinner app:validateMinLength> that accepts parameter type 'int' If a binding adapter provides the setter, check that the adapter is annotated correctly and that the parameter type matches
Hi guys, nice to find other Maceioenses round here :)
So, I need to define an error message for empty validation (by the way, the empty may be used as a required validation? Maybe you can rename it or something like that), so how I'm suppose to get it?
I tried to add app:validateEmptyMessage="@string/<some_string>"
, similarly to the date validation, but this not exists :/
Can you help me oh this?
app:validateEmpty="@{safeUnbox(milkingStatus==0) ? true : false}"
always returning true value.
What is the point to validate the hidden inputs?
I have used dagger too as a dependency and when i added this as an library project it build successfully, But at the time of application running i got the errror for the import statement in activity that
Warning:The following options were not recognized by any processor: '[android.databinding.minApi, android.databinding.enableDebugLogs, android.databinding.sdkDir, android.databinding.bindingBuildFolder, android.databinding.enableForTests, android.databinding.modulePackage, android.databinding.generationalFileOutDir, android.databinding.xmlOutDir, android.databinding.artifactType, android.databinding.printEncodedErrors, android.databinding.isTestVariant]'
Any Help is appreciated.
Hi again,
I just migrated to AS 3.0 beta to have more support with Room lib, but now your lib is not working anymore :/
Maybe it is a AS bug, not yours, but could you check this?
I didn't changed any validator property, just migrated to the last AS beta version (and obligatorily, gradle version to 4.1 and Android Plugin to 3.0.0-alpha7). It's printing the following:
****/ data binding error ****msg:Cannot find the setter for attribute 'app:validateEmpty' with parameter type boolean on android.support.design.widget.TextInputEditText.
.
Here is my xml:
<android.support.design.widget.TextInputLayout
android:id="@+id/tiXpto"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent">
<android.support.design.widget.TextInputEditText
android:id="@+id/edXpto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:hint="@string/add_xpto_name"
android:inputType="textPersonName"
android:text="@={xpto.name}"
android:textSize="16sp"
app:validateEmpty="@{true}"
app:validateEmptyAutoDismiss="@{true}"
app:validateEmptyMessage="@{@string/field_is_required}"/>
</android.support.design.widget.TextInputLayout>
Any help will be apreciatted.
Email validation is ignored when app is launched with release variant.
Odd that the same code built with debug variant works perfectly, as well as the other validations (telephone and empty fields).
Assured that XML has the correct attributes:
app:validateType='@{"email"}'
And in code:
validator.enableFormValidationMode()
validator.validate(editTextsCollection)
The dependency is the last one:
implementation 'com.github.Ilhasoft:data-binding-validator:2.0.0
'
Is there a reason that this library does not have a license? I love the idea of this project and would like to try out these binding validations for work but having no license is a deal-breaker. Having a non-restrictive license like Apache 2.0 or MIT would enable myself and many others to use this library.
I'm running into an UI issue, causing the error message under a TextInputLayout to flicker if multiple rules are used. Please see the gif below.
What is happening is, if multiple rules are used, for instance MaxLengthRule
and MinLengthRule
, when the user starts typing, MaxLengthRule
is valid, so the validation library disables the TextInputLayout
error, then proceeds to validate MinLengthRule
. This rule is not valid right when the user starts typing so the validation library adds the error back. This is happening each time the user types.
I downloaded the sample app for the data-binding-validator
library provided in this repository, and reduced activity_main.xml
to this:
`
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:focusableInTouchMode="true"
android:padding="8dp"
android:orientation="vertical">
<com.google.android.material.textfield.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Name"
app:validateMaxLength="@{10}"
app:validateMaxLengthMessage="@{@string/custom_error_max_length}"
app:validateMinLength="@{4}"
app:validateMinLengthMessage="@{@string/custom_error_min_length}"
app:validateEmpty="@{true}"
/>
</com.google.android.material.textfield.TextInputLayout>
</LinearLayout>
</ScrollView>
`
Then in the MainActivity
`public class MainActivity extends AppCompatActivity implements Validator.ValidationListener {
private static final String TAG = "MainActivity";
private ActivityMainBinding binding;
private Validator validator;
@Override
public void onValidationSuccess() {
saveToDatabase();
}
@Override
public void onValidationError() {
Toast.makeText(MainActivity.this, "Dados inválidos!", Toast.LENGTH_SHORT).show();
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
binding = DataBindingUtil.setContentView(this, R.layout.activity_main);
binding.name.addTextChangedListener(new TextWatcher() {
public void afterTextChanged(Editable s) {
validator.validate(binding.name);
}
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
public void onTextChanged(CharSequence s, int start, int before, int count) {
}
});
validator = new Validator(binding);
validator.setValidationListener(this);
validator.enableFormValidationMode();
}
private View.OnClickListener onValidateNameClickListener = new View.OnClickListener() {
@Override
public void onClick(View v) {
validator.validate(binding.name);
}
};
private View.OnClickListener onValidateAllClickListener = new View.OnClickListener() {
@Override
public void onClick(View v) {
if (validator.validate()) {
saveToDatabase();
} else {
Toast.makeText(MainActivity.this, "Dados inválidos!", Toast.LENGTH_SHORT).show();
}
}
};
private View.OnClickListener onValidateAllWithListenerClickListener = new View.OnClickListener() {
@Override
public void onClick(View v) {
validator.toValidate();
}
};
private void saveToDatabase() {
Log.i(TAG, "Salvar os dados no banco de dados");
}
}
`
If you then run the app, you will be able to see the flickering. After playing around with it some more, I believe I may have found a solution for the issue. Please see the details below.
In MinLengthRule.java
and MaxLengthRule.java
I included the additional logic below in each of their onValidationSucceeded()
methods:
@Override public void onValidationSucceeded(TextView view) { TextInputLayout textInputLayout = EditTextHandler.getTextInputLayout(view); if(null != textInputLayout.getError() && textInputLayout.getError().equals(errorMessage)) { EditTextHandler.removeError(view); } }
This only allows the rule to dismiss its own error, by checking to make sure the current error being displayed, matches the rules error, that is trying to dismiss the error. This eliminates the flickering.
This may not be the best approach to fix this issue, so I'm completely open to other ideas. If you feel this is a viable fix, or determine a better way of resolving the flicker, would you be able to update the library with a solution? We use this library extensively in our project here at work, so it would be great of we could continue to use it, instead of having to find another option.
Thanks any advance for any help you are able to provide.
error: cannot find symbol
addMapper(new br.com.ilhasoft.support.validation.DataBinderMapperImpl());
^
symbol: class DataBinderMapperImpl
location: package br.com.ilhasoft.support.validation
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
1 error
1 warning
:app:compileDebugJavaWithJavac FAILED
Without the library all works.
is that possible make directly a range validation on editText with "number" input type? I now by using Regex I can do the validation but I want to know if there is a direct validation.
thank you
Is there a way to validate CNPJ? Or can I implement a custom validator that does more than only check if matches the regex pattern?
I'm using android studio 2.4(beta), And when I try to set a custom validation message like app:validateEmptyMessage
I get this error
Error:(68) No resource identifier found for attribute 'validateEmptyMessage' in package 'com.bamooz.vocab.deutsch'
Pls fix this problem
I want to run validation so that the submit button can be disabled until all the fields are valid. But calling validate() causes the error text to appear on the fields before the user has even had a chance to type anything in them which is a harsh UX.
An OnFocusChangeListener on each field could set whether the error message is shown or not, but I don't see an option/property to set for that?
Hello guys,
I just tried to use the library puting compile "com.github.Ilhasoft:data-binding-validator:1.0.0" on gradle file, but always appear the message "failed to resolve: com.github.Ilhasoft:data-binding-validator:1.0.0"... I've tried to put with implementation like I saw in closed issues, but it's stil the same. I've also tried with other versions. Is it necessary any dependecy? What I am doing wrong? It seems a simple mistake, but I can't go on.
Tks!
The library is not working on Android SDK 28.
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.