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.

Float type validateValue not check not a number.

See original GitHub issue

OpenUI5 version: 1.50

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

Steps to reproduce the problem:

  1. Input --0.1
  • What is the expected result? Remove focus, error message will show in input, validateValue should throw an error jietu20171205-121324 2x

  • What happens instead? validateValue did not throw an error. Instead, in onContinue, oBinding.getType().validateValue(oInput.getValue()) returned undefined, it should not pass validate. But if I input 200, oBinding.getType().validateValue(oInput.getValue()) will throw an error

In Float.prototype.validateValue, there seems not check for isNumber: https://github.com/SAP/openui5/blob/3a212d2b66e7935986b5507c5f520c99ec645497/src/sap.ui.core/src/sap/ui/model/type/Float.js#L87

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
goligocommented, Dec 6, 2017

Hello TinaC,

works as expected. validateValue is meant to validate the constraints on float values, it doesn’t need to be able to handle strings. When entering a string which does not represent a valid float number parseValue will throw an error.

So whenever a value is entered, first parseValue is called to convert the string value into a number. Only if parsing was successful, validateValue will be called with the result.

Regards, Malte

1reaction
TinaCcommented, Dec 11, 2017

Hi Malte,

  1. I just make some changes to official custom input type: https://sapui5.hana.ondemand.com/#/sample/sap.m.sample.InputChecked/preview validateValue is used to make my custom validate rule for this type.

  2. I did not use parseValue, just add it in case there is an error for parseValue not found.

  3. So here comes to my question: ui5 just check the float value is within boundary conditions, but missing the check for the value is a float/number

Regards, Tina

Read more comments on GitHub >

github_iconTop Results From Across the Web

How do I check that a number is float or integer?
Here are efficient functions that check if the value is a number or can be safely converted to a number: function isNumber(value) {...
Read more >
Custom Data Types in SAPUI5 - SAP Blogs
For validating whether we're dealing with a valid credit card number or not, we will implement the Luhn's algorithm in our validateValue method....
Read more >
qcodes.validators — QCoDeS 0.37.0.dev48 documentation
Validator for numerical numpy arrays of numeric types (int, float, complex). ... Min value allowed, default None for which min value check is...
Read more >
Validate Integer and Decimal Values in SQL Server
Learn how to validate specific use cases for integer and decimal values in SQL Server.
Read more >
Valdi — Valdi v0.3.0 - HexDocs
iex> Valdi.validate(10, type: :integer, number: [min: 10, max: 20]) :ok iex> ... validate(value, validators) ... Validate value if value is not nil.
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