a.daniello Posted October 5, 2014 Report Posted October 5, 2014 Hi, i'm trying to add an "input rule" in "universal module" to check if the field "url" is a specific subdomain. I'm using this code in "input rules": {"url":{ "valid":{ "rule": {"matches", "/^[\w.-]+\.midomain\.(com|it)$/"}, "message":"URL is invalid" } }} But seems that no rule is applied so i can write anything in my "url" field. Can someone help me, please? Achille Quote
0 Tyson Posted November 4, 2014 Report Posted November 4, 2014 Not sure why I didn't see this sooner. You probably already discovered the issue, but when specifying parameters (the regex) to a callback ("matches"), an array format is expected. JSON arrays use brackets rather than braces, so the fix would be to simply change the rule from: "rule": {"matches", "/^[\w.-]+\.midomain\.(com|it)$/"}, to "rule": ["matches", "/^[\w.-]+\.midomain\.(com|it)$/"], Quote
0 a.daniello Posted November 4, 2014 Author Report Posted November 4, 2014 Finally! Thanks Tyson, but nothing: it not works! I wrote rules as in http://docs.blesta.com/display/user/Universal+Module#UniversalModule-InputRules but also with your suggestion no check is processed (i can write everything, without control). Is there a mode to check if order form use this rule? Thanks, Achille Quote
0 Tyson Posted November 4, 2014 Report Posted November 4, 2014 You could only test adding/editing a service to see if the rules are validating by checking whether an error is generated. Is your Input Rule set for the Package or Service fields? If you create a product with the following service field input rule: {"hostname":{ "valid":{ "rule":"isEmpty", "negate":true, "message":"Hostname must not be empty" } }} ..and you have a "hostname" service field set, you can check whether the rule validates by adding a service. Go to add a service from the admin interface, select this product, and don't set a value for the hostname. When you click to Continue, an error should be shown saying "Hostname must not be empty". That will tell you whether the rules are validating. I tested this myself and find it to be working properly. Quote
Question
a.daniello
Hi,
i'm trying to add an "input rule" in "universal module" to check if the field "url" is a specific subdomain.
I'm using this code in "input rules":
But seems that no rule is applied so i can write anything in my "url" field.
Can someone help me, please?
Achille
3 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.