guards.js

View the Project on GitHub on-site/guards.js

Preconditions

Defining preconditions

Sometimes guarding a form is not so black and white. For example, you may want to have a particular guard only apply under certain circumstances. Perhaps a guard only applies if a checkbox has been checked, or if any of a set of fields have values. Under these circumstances, you need to use the precondition method. This will allow you to define a precondition for the guard, which blocks the guard from being evaluated if the precondition returns false. Any other return value (including no return) will be treated as though the guard is ok to be executed. See the example below to get an idea how this can be used.

Leave blank to provide no address:



,

previous next