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

label & groups should have global definitions per element #11

Open
troyji opened this issue Aug 14, 2011 · 3 comments
Open

label & groups should have global definitions per element #11

troyji opened this issue Aug 14, 2011 · 3 comments
Assignees

Comments

@troyji
Copy link
Contributor

troyji commented Aug 14, 2011

Every constraint allows for a label and groups. In most cases, all constraints for an element need to have the same value for these parameters. I propose that there should be a way to define these values globally for all other constraints on the element. This could be achieved with either a special constraint, or through another attribute.

Additionally, there are some scenarios where you would want the label and/or groups to be different per constraint. Therefore, the constraint parameters for them should remain. If they are present, they would override the globally defined label or group. This would also allow for backwards compatibility.

Ex.

<input type="text" class="regula-validation" 
  data-constrains="@Label(value='My Label') @Groups(value='MyGroup') @Required @IsNumeric @Min(value=0)"/> 

Or

<input type="text" class="regula-validation" label="My Label" groups="MyGroup" 
  data-constrains="@Required @IsNumeric @Min(value=0)"/> 
@vivin
Copy link
Owner

vivin commented Aug 14, 2011

That's an interesting idea. I think it would require some more thought as to the best way to implement this. Using predefined groups for all constraints attached to an element is certainly attractive.

@ghost ghost assigned vivin Aug 14, 2011
@troyji
Copy link
Contributor Author

troyji commented Sep 2, 2011

I am thinking that we should just add a new html attribute for adding element-wide variables to an element. Perhaps custom constraints could have access to this feature too. You would still be able to override these on the constraint level if needed as well.

<input type="text" 
    data-variables="%label('My Label') %groups('grpA') %myCustVar('someVal')" 
    data-constraints="@Required @Number @MyCustConst"/>

@vivin
Copy link
Owner

vivin commented Sep 2, 2011

That certainly seems possible; would still need to think a bit more about this one.

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

No branches or pull requests

2 participants