Supported by: Community
NetefxValidator is a class for form validation, so it replaces the RequiredFields() validator.
When you build forms in silverstripe, you can use a RequiredFields-validator (official documentation). This validator defines which fields have to be filled in. But often this is not enough. If you want to make sure, that your form (frontend or backend) is filled correctly, your rules have to be more restrictive. There are specific fields in sapphire, like the EmailField() (official API documentation), which have a validationrule themeselves. But it doesnt make sense to define a separate class for every field of your form just for validation purposes.
You can use the NetefxValidator to perform any validation you want. You can write NetefxValidatorRules of several types and add them to the validator. Each rule belongs to a form field, has a type, parameters and an error message, which is displayed to the user, if the rule does not validate. There are different types of rules, like REQUIRED rules, which simply express, that a field has to be filled, numeric rules, which are used to compare an input field to a fixed value or to other input fields, REGEXP rules, which expect a regular expression to check for and FUNCTION rules, in which you can use your self-written functions or library functions. Finally you can combine rules to a new rule using logical rule combination.
Just move the folder "NetefxValidator" to your projectfolder.
Compatible with: SilverStripe 2.4.4, 2.4.5
To get a preview of our next release, download the latest build of unstable git master branch here. Please
be careful: this is more likely to contain bugs, especially on modules undergoing a lot of development.
SHA hash: 7b5af6d0064dd768ecee124012acf9c5164c5d32
Build Date: 2013-09-17
Unstable Git access: