Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request] Add to each attr a conditionality option for require-attrs rule #169

Open
RPComputer opened this issue Dec 12, 2023 · 6 comments

Comments

@RPComputer
Copy link

RPComputer commented Dec 12, 2023

Hello,
I think that it would be interesting to add to the require-attrs rule the conditionality option for requirement.

For example:

Given the element: <element attr1="v1">
Rule setting:

{
    "tag": "element",
    "attr": "attr2",
    "conditions":[
         {
              "attr": "attr1"
              "value": "v1",
              "kind": "present"
          }
    ]
}

This would make the attr2 attribute required for the element tag only if the attr1 attribute is present with value v1.
Another possibility could be the reverse: if an attribute is present/not present the following list of attributes are required.
I know that the conditions possibilities might escalate quickly but supporting a couple of basic ifs would be very helpful.

What do you think?

@yeonjuan
Copy link
Owner

yeonjuan commented Dec 12, 2023

Hi! @RPComputer Thanks for the suggestion!. This seems like a nice feature.
I think it should check with AND condition when there are multiple conditions. What do you think?

@RPComputer
Copy link
Author

Hi @yeonjuan, yes as default condition logical join AND sounds right!
I'm uncertain for the configuration logic order of the conditioned attrs: should the configuration put requirements under a logic condition or each attribute should have its optional condition?
For simplicity it might be easier the first option, what do you think?

@yeonjuan
Copy link
Owner

Hi @RPComputer

each attribute should have its optional condition?

For now, I think the second option is appropriate because the first option would make a breaking change..!

@RPComputer
Copy link
Author

Hi @yeonjuan! Sounds good to avoid breaking changes.
Should I try to implement it or you want to take care yourself?

@yeonjuan
Copy link
Owner

@RPComputer
If you'd like to implement it yourself, I'd be very grateful for a PR 👍 , otherwise I'll implement it myself, but it may delay the completion of the implementation a bit.

@RPComputer
Copy link
Author

Hi @yeonjuan,
I'll see what can I do and if it works I'll make a PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants