You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to create a new custom rule to check if field_name is similar to description. Code works fine if it is exact match ie if description is "first_name" and field_name is "first_name" but it does not work if description is "First Name" or "first name" trying to use regex replace and replace but unable to get the solution. Below is the code which I am using, can you please check and suggest what can be modified to get it working?
> # rule: Check_desc {
> # description: "This rule checks if description is similar to field name for any field added (dimension/measure)."
> # match: "$..view.*[dimension,dimension_group,measure][?(@.hidden!==true)]"
> # expr_rule: ($if ($boolean ($match
> #"^" ::match:$name "$"
> #($concat "^" ($replace ::match:description " " "_") "$")))
> #($concat "Field name `" ::match:$name "` and description `" ::match:description "` is similar . Please change it.")
> #true)
> #;;
> #}
The text was updated successfully, but these errors were encountered:
It looks like there's not a great built-in "regex replace" method within Liyad. It could be added if this gets too complex, but for a pretty simple set of characters, you can just replace each one independently with the string replace function.
I put these in a "pipe" so it should be easier to add more normalizations if you want:
($let normalize (-> (x) ($pipe x
(-> (x) ($any x ""))
(-> (x) ($__call x toLowerCase))
(-> (x) ($replace-all x "_" ""))
(-> (x) ($replace-all x " " ""))
(-> (x) ($replace-all x "?" ""))
)))
(==
(normalize ::match:$name)
(normalize ::match:description)
)
I might even add a built-in rule for this, so I'll leave this open
Hi @fabio-looker,
I am trying to create a new custom rule to check if field_name is similar to description. Code works fine if it is exact match ie if description is "first_name" and field_name is "first_name" but it does not work if description is "First Name" or "first name" trying to use regex replace and replace but unable to get the solution. Below is the code which I am using, can you please check and suggest what can be modified to get it working?
The text was updated successfully, but these errors were encountered: