Have been playing around with manual validation in cbWire components as described here in the docs.
While automatic validation works fine, I am having trouble with calling the validate() function manually.
For example, triggering validate() in the submitForm action in the following component does not work but throws an error saying No matching function [VALIDATE] found.
<!--- Template --->
<cfoutput>
<form wire:submit.prevent="submitForm">
<div>
<input wire:model.lazy="email" type="email" placeholder="Enter your email...">
<label for="email">Email address</label>
<cfif validation.hasErrors( "email" )>
<div class="text-danger">
#validation.getAllErrors( "email" ).first()#
</div>
</cfif>
</div>
<!--- Show if the form submission is successful --->
<cfif success>
<div>
<div class="text-center mb-3">
<div class="fw-bolder">Form submission successful!</div>
</div>
</div>
</cfif>
<button
class="btn btn-primary text-uppercase <cfif validation.hasErrors()>disabled</cfif>"
type="submit">Send</button>
</form>
</cfoutput>
<!--- Component Blueprint --->
<cfscript>
// Validation constraints
constraints = {
"email": {
"required": true,
"type": "email"
}
};
// Data properties
data = {
"email": "",
"success": false
};
// Actions
function submitForm() {
var result = validate(
target=data,
constraints={
"email": { required: true, type: "email" }
}
); // ValidateResult object
}
</cfscript>
Seems like the cbValidation mixins are not available in the component.
Any pointers what I’m doing wrong?
Stack:
cbWire@be 3.1.0-snapshot (also tried cbWire 3.0.0)
cbValidation 4.3.1+25
Coldbox 7.1.0+10