'search' constraint for sap.ui.model.type.String causing SyntaxError in XML view
See original GitHub issueOpenUI5 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:
- Created 7 years ago
- Comments:11 (7 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
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.
I have created backlog item CPOUI5MODELS-920 for tracking.