cfvonner
07/19/2022, 11:01 PM=>
) expression. Here's my cbValidation code:
cbValidation.validateOrFail(
target = rc,
constraints = {
facilityid : {
required : true,
requiredMessage : "A {field} (FID) must be provided."
type : "integer",
typeMessage : "The {field} must be a whole number greater than 1.",
min : "1",
minMessage : "The {field} must be a whole number greater than 1.",
udf : function ( value, target ) {
if( isNull( arguments.value ) ) return false;
return ecFacilityService.getByFacilityID( facilityid = arguments.value, lazyload = true ).len() > 0;
},
udfMessage : "There are no facilities with a {field} value of {rejectedValue}."
}
}
);
This throws a ColdFusion "Invalid Construct: Either argument or name is missing". Not sure what I'm doing wrong.chris-schmitz
07/20/2022, 8:13 AMrequiredMessage
text.cfvonner
07/20/2022, 3:07 PMcfvonner
07/20/2022, 3:07 PMAdam Cameron
Adam Cameron
coldfusion.compiler.ParseException
, and Lucee gives a - rather meaningless - lucee.runtime.exp.TemplateException
.
It's interesting that a Lucee compilation exception is in a "runtime" package. And I wonder what exp
means?cfvonner
07/20/2022, 9:00 PMcbValidation.validateOrFail
). The problem was I forgot that I had added that requiredMessage line before I added the udf line, and I assumed the error was coming from the way the udf part was written.Adam Cameron
Adam Cameron
cfvonner
07/20/2022, 9:43 PMudf
key to the constraints and it's associated closure, and therefore that the error was coming from a compile error on that closure.
Oddly, in testing something similar on TryCF to try to narrow down where the problem was coming from (I created a function assigned to a variable), it threw errors on CF2018 but not on any other version (I tried 11, 2016 & 2021 to be sure). I wonder if there was a closure/function expression error on CF2018 that was later fixed by a hotfix that hasn't been installed on TryCF yet. When I tried the same code on my local CommandBox-driven CF2018 server running the latest hotfixes it ran fine. Which left me very perplexed.
Here's the Gist that failed on TryCF: https://gist.github.com/cfvonner/363ba307b239fbb66b615569f2c9b0aa / https://trycf.com/gist/363ba307b239fbb66b615569f2c9b0aa?engine=acf2018Adam Cameron
Adam Cameron
Adam Cameron