You are viewing documentation for v1.1.x. Change

verifies()

Description

Instructs Wheels to verify that some specific criterias are met before running an action.

Function Syntax

verifies([ only, except, post, get, ajax, cookie, session, params, handler, cookieTypes, sessionTypes, paramsTypes ])

Parameters

Parameter Type Required Default Description
only string No List of action names to limit this verification to.
except string No List of action names to exclude this verification from.
post any No Set to true to verify that this is a POST request.
get any No Set to true to verify that this is a GET request.
ajax any No Set to true to verify that this is an AJAX request.
cookie string No Verify that the passed in variable name exists in the cookie scope.
session string No Verify that the passed in variable name exists in the session scope.
params string No Verify that the passed in variable name exists in the params struct.
handler string No Pass in the name of a function that should handle failed verifications. The default is to just abort the request when a verification fails.
cookieTypes string No List of types to check each listed cookie value against (will be passed through to your CFML engine's IsValid function).
sessionTypes string No List of types to check each list session value against (will be passed through to your CFML engine's IsValid function).
paramsTypes string No List of types to check each params value against (will be passed through to your CFML engine's IsValid function).

Examples

<!--- Tell Wheels to verify that the `handleForm` action is always a `POST` request when executed --->
<cfset verifies(only="handleForm", post=true)>

<!--- Make sure that the edit action is a `GET` request, that `userId` exists in the `params` struct, and that it's an integer --->
<cfset verifies(only="edit", get=true, params="userId", paramsTypes="integer")>

<!--- Just like above, only this time we want to redirect the visitor to the index page of the controller if the request is invalid and show an error in The Flash --->
<cfset verifies(only="edit", get=true, params="userId", paramsTypes="integer", handler="index", error="Invalid userId")>