Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

All other Modules /

Discuss all other Modules here.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba


Go to End

23 Posts   6306 Views


Community Member, 83 Posts

7 March 2011 at 2:46am

Edited: 07/03/2011 8:57am

Hi all,

we released a module for validation, which also works in Modeladmin.
It gives you more possibilities than RequiredFields but has no javascript validation (at this time).

You can download it here:

You will also find a detailed documentation there.

Use this forum thread for questions and comments on the module.



Community Member, 83 Posts

15 March 2011 at 8:41am


we added some usefull rules.
So NetefxValidator 0.4 can be downloaded now.

Whats new?

1) new rule "ISONEFROM"

if you have a dropdownfield you can define a number of elements which return TRUE if you choose one of them. This can be used for example in DataObjects that are Translatable. So maybe in each language your dropdownfield has one option that should return TRUE. But now you can define a validationrule that contains the IDs for the "good" options of all languages.

2) new rule "ISNOTONEFROM"

Of course its just the opposite of ISONEFROM. If one of these values is selected, the rule returns FALSE.

3) new rule "MINCHARACTERS"

easy to eyplain: if the users fills less than x letters, the validatorrule returns FALSE

$rule_FirstName_MinChar = new NetefxValidatorRule("FirstName", "MINCHARACTERS", array('2'), "Please enter at least two characters");

Note: this can also be done with REGEXP rules, which were already available in 0.3 . But MINCHARACTERS is easier to use.

4) new rule "MAXCHARACTERS"

similar to "MINCHARACTERS"


gives you the possibility to define MIN and MAX in one rule.

$rule_FirstName_CharBetween = new NetefxValidatorRule("FirstName", "CHARACTERSBETWEEN", array('2','20'), "Please enter between 2 and 20 characters");

6) new rule "XOR"

the new XOR rule belongs to the set of rule combinations.
A XOR rule validates, if and only if exactly one of the two rules, which are given as parameter, validates.

7) updated documentation:

- forgotten to mention the rules "DateIsMinDaysAfterToday" and "DateIsMinDaysBeforeToday"
- better example for own validation functions.

so, i am wayting for the first feedback.


Community Member, 9 Posts

17 March 2011 at 12:43am

Edited: 17/03/2011 12:44am

Hi lx,

I would like to thank you for releasing this very useful module.

The possibility to call own functions for validation is really great and is one of the things I was missing in Silverstripe/Sapphire.

Have you tested your validator in DOM-Popups? I've got it working, but if validation fails, the form-content is missing, so on any error you've got through validation you have to reenter all details in the form...
Maybe there's something I forgot? All I did, was to extend from DataObjectManager_Popup, implement the validator-stuff in its constructor and let my DataObjectManager use this custom Popup-class...

Anyway, thanks again for this module,


PS: There might be a small error in your documentation, I think in the part about Function-Rules, this example

class MyLibrary {
                                      public function MySpecialValidationFunction ($data, $args) {

should probably be static...
class MyLibrary {
                                      public static function MySpecialValidationFunction ($data, $args) {


Community Member, 83 Posts

17 March 2011 at 12:59am

Hi s!m,

thanks for your answer.

I didnt test it in DOM, because I dont use the DataObjectManager.
Is RequiredFields() working correctly in DOM?

You are right. This is an error in the documentation.
I will fix it asap.



Community Member, 9 Posts

17 March 2011 at 1:59am

Hi lx,

RequiredFields aren't working either, so the problem is not your module, thanks for your hint...:)

Best regards,


Community Member, 130 Posts

20 March 2011 at 7:31am

Edited: 20/03/2011 8:01am

Hi, lx,

Great Module, and thanks for pointing me to this thread. Exactly what I needed.

Im having an issue with "OR" rules though. This looks correct according to the documentation, but the field is not validating any of the rules.

Any ideas?

- - - - -
It appears that the OR rule doesn't play nice with the UNIQUE rule.

If I separate the UNIQUE rule from the OR rule it works fine.
- - - - -

$rule_FirstName_Required = new NetefxValidatorRule("FirstName", "REQUIRED", "", "A first name is required");

$rule_LastName_Required = new NetefxValidatorRule("LastName", "REQUIRED", "", "A surname or last name is required");
$rule_Email_Unique = new NetefxValidatorRule("Email", "UNIQUE", array('Email','LandingFormSubmission'), "no message");

$rule_Email_Required = new NetefxValidatorRule("Email", "REQUIRED", "", "no message");

$rule_Email_Valid = new NetefxValidatorRule("Email", "REGEXP", array("/[^@]+@[a-zA-Z0-9._-]+\.[a-zA-Z]/"), "no message");

$rule_Email = new NetefxValidatorRule("Email", "OR", array($rule_Email_Unique,$rule_Email_Required,$rule_Email_Valid), "Email must be valid and only one email per registration may be used");

$validator = new NetefxValidator($rule_FirstName_Required, $rule_LastName_Required, $rule_Email);



Community Member, 83 Posts

20 March 2011 at 8:28am

Hi Prawnstar,

First I have to mention that logical rules do only combine 2 rules (not 3 at once).

But in your form i dont think that you really want an OR combination,
because I think Email is REQUIRED AND has to be UNIQUE AND has to be valid, right ?

So just add all these 3 rules to your NetefxValidator (without the need to logically combine them).
Make sure , that the REQUIRED rule is the last rule you add to the validator.)

If you really want to combine 3 rules with OR you have to combine 2 of them with OR and then combine the third with the combined rule of 1 and 2. (In such a case you come to a point where logically rule combination is getting difficult and needs a lot of concentration. These are at least my experiences :)

I hope this helped you


Community Member, 130 Posts

21 March 2011 at 8:03am

Ah! You're correct. That would be AND, not OR.

That makes total sense, thanks!


Go to Top