[PLAS-3] Users need to associate variable values with matched substrings using wildcards Created: 08/Jan/20 Updated: 14/Jan/20 Resolved: 14/Jan/20 |
|
| Status: | Done |
| Project: | plastic |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | New Feature | Priority: | Medium |
| Reporter: | Allan Clarke | Assignee: | Allan Clarke |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | 3 days | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | 3 days | ||
| Description |
|
Proposal B: this is about providing a simplified wildcard-like matching for use in input schemas If a designer knows how to use regex effectively then they won't be bothered much by creating a morpher. So making a simpler matching mechanism will make it easier on less knowledgable users. An example
|*${abc}/${def}*|
So the bars | are required and mark the beginning and end of a "wildcard expression" (the full value, no prefix, no suffix) Here is a fuller example (from discussion with Qasim)... input schema...
{ "device": { "id": "|*/${aid}/*|", "bw": "${bandwidth}" }}
payload...
{ "device": { "id": "CX02DPM 43/DEV-53/aus Orlando", "bw": "1000" }}
resulting variable binding...
${aid} = "DEV-53"
${bandwidth} = 1000
|
| Comments |
| Comment by Allan Clarke [ 14/Jan/20 ] |
|
The below was the original Proposal A and the one implemented in the main part of this story was Proposal B. But B won out due to its Proposal A: This is about exposing use of regex to schema designers. For reference, an example regex: /^.\s(.*?)\s(.*?).*$/ Allow user to do this: ${abc=~/...regex.../} Note that = is used for assignment of default value and =~ is used for association of regex In the example above, there are up to 2 captures, which would result in variable bindinds for abc/1 and abc/2 Note the way the variable is named is a reminder that it is from a regex Any non-matches mean that there will be no binding for those variables and a likely complaint from Plastic. User will need to know it was a bad regex, but there is a hint due to unique variable name structure.
|