question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Trigger validation constraints for empty value

See original GitHub issue

OpenUI5 version: all

Browser/version (+device/version): all

URL (minimal example if possible): https://plnkr.co/edit/l6XtmBXqOtlNFBuK2CtA?p=preview

What is the expected result? There is no way to check all constraints for all/one control in a view. The “hack” to get and set the current value doesn’t work for empty input fields.

What happens instead? noting for empty input fields

Request: Provide a simple api to check a constraints for a list of controls and return a single true/false value: this.getView().validateControls(['inputA','inputB','inputC']) Or trigger it at least for strings with a length of 0

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
bkrrrrcommented, Feb 26, 2018

I can’t see the point in copying valdiator.js into every ui5 app.

Form with a mandatory input field can’t use the default validation without a huge junk of custom code. That’s odd and should be changed. And it can’t be done in a elegant way, because validation isn`t triggered for empty fields.

0reactions
svbendercommented, Apr 5, 2018

Hi, During data binding a check for empty input fields only happens if it was changed.

As you have already done in the “Validator.js”, you can validate a empty property by fetching the binding: https://openui5.hana.ondemand.com/#/sample/sap.m.sample.InputChecked/code/C.controller.js

jQuery.each(aInputs, function (i, oInput) {
	var oBinding = oInput.getBinding("value");
	try {
		oBinding.getType().validateValue(oInput.getValue());
	} catch (oException) {
		oInput.setValueState("Error");
		bValidationError = true;
	}
});

Unfortunately there are no plans to implement a generic solution to validate multiple (empty) controls.

Best regards, Sven

Read more comments on GitHub >

github_iconTop Results From Across the Web

trigger to validate empty fields - Salesforce Developers
I'm trying to write a trigger to make sure certain fields are not empty based on the status that is chosen. I have...
Read more >
Empty input value does not triggger @NotNull but it triggers ...
i have this entity: import javax.validation.constraints.NotNull; import org.hibernate.validator ...
Read more >
Java Bean Validation Basics - Baeldung
@NotEmpty validates that the property is not null or empty; can be applied to String, Collection, Map or Array values. @NotBlank can be...
Read more >
Constraint validation - HTML: HyperText Markup Language
Complex constraints using the Constraint Validation API​​ setCustomValidity() to set the result of the validation: an empty string means the  ...
Read more >
Chapter 3. Declaring and validating method constraints
Depending on the interception facility you use for triggering method ... an executable with return value but no parameters (the constraint applies to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found