GuySartorelli / silverstripe-composable-validators

Reusable validators that can be composed together for use in the Silverstripe framework
BSD 3-Clause "New" or "Revised" License
5 stars 0 forks source link

Silverstripe Composable Validators

Thank you to Signify for making this module possible.

This module provides a number of reusable composable validators (including AJAX validation) for use both in the CMS and in frontend forms.

Make sure you check out the extensions documentation at a minimum - some of these should be applied in almost all projects using this module.

If your project has any automated client-side tests, or you are implementing a validator to be compatible with this module, please make sure you read the client side tests documentation.

Install

Install via composer:

composer require guysartorelli/silverstripe-composable-validators

Gotchas

Form submission with an AjaxCompositeValidator

The AjaxCompositeValidator adds a submit handler to your form. This doesn't always interact well with other submit handlers, and can result in either front-end validation being skipped or the form not submitting the way you expect it to, depending on which submit handler gets the event first. For best results, don't add additional submit handlers to the form.

If you're using the AjaxCompositeValidator on a form that uses undefinedoffset/silverstripe-nocaptcha 2.3.0 or higher, you should disable form submission handling for the NocaptchaField in that form (see instructions in the nocaptcha docs).

Available Validators

Abstract Validators

Traits