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.

'search' constraint for sap.ui.model.type.String causing SyntaxError in XML view

See original GitHub issue

OpenUI5 version: 1.28

I want to use a search constraint to valuate an user input. It is meant for a sap.ui.model.type.String type. The regex I want to use has been tested in online tools and works for controller based validation approaches (e.g. change).

I am not sure what is causing the SyntaxError. Is it ‘search’ or the regex?

                <Label required="true" text="Staff - search"/>
                <Input 
                  placeholder="AB-12345-C" 
                  value="{ path: 'StaffNr', 
                           type : 'sap.ui.model.type.String',
                           constraints: {
                             search: '^[a-zA-Z]{2}-\d{5}-[a-zA-Z]{1}$'
                           }
                         }"/>



  Object {name: "SyntaxError", message: "Bad string", at: 142, text: "{ path: 'Meins',                  type : 'sap.ui.m…}-[a-zA-Z]{1}$'                 }               }"}

Issue Analytics

  • State:open
  • Created 7 years ago
  • Comments:11 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
codeworriorcommented, Apr 27, 2016

The top level parser for binding strings (base.BindingParser) calls the parseJS when it detects a binding object. So inside a binding object you don’t need to escape curly braces, only the Javascript escaping is necessary. When curly braces occur top level in the binding string (outside a binding object), they need to be escaped.

Might be a bit hard to understand and was mainly driven by the implementation, but at the end it reduces the necessary escaping.

Last but not least, things get worse in an XMLView as the embedding of the binding string in an XML attribute might require additional escaping (XML entities). That’s a post processing (for the encoder) resp. a preprocessing for a decoder. Means: when writing a binding string in an XMLView, first follow the above rules for escaping a binding strings, then apply the rules for XML escaping to the result.

0reactions
uhlmannmcommented, Apr 1, 2022

I have created backlog item CPOUI5MODELS-920 for tracking.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Email address regex causes syntax error in UI5 - Stack Overflow
If the search property has a string value instead of a RegExp object, you have to escape the escape character. I.e. \\ instead...
Read more >
attachValidationError not triggered when using xmlview
I created an xml view with a control: <Input id="titleIncidentId" value="{path:'/Title', type: 'sap.ui.model.type.String', constraints: ...
Read more >
SQL error messages and exceptions - Oracle Help Center
The column <columnName> on table <tableName> has been modified by adding a not null constraint. 01504, The new index is a duplicate of...
Read more >
Database Engine events and errors - SQL Server
Consult this MSSQL error code list to find explanations for error messages ... Xml data type methods are not supported in check constraints....
Read more >
Expression Binding - Documentation - Demo Kit - SAPUI5 SDK
An expression binding is specified in an XML view by one of the following ... relate to OData types, see the sap.ui.model.odata.type API...
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