leftbower
08/08/2023, 6:20 PMUniqueValidator with the cbValidation module? It bombs out on line 61:
var IdValue = invoke( target, "get#validationData.keyProperty#" );
with this error:
component [models.myModel] has no function with name [getid]
Indeed, my model does not have an id property nor a getter for it. Is this a requirement?Ryan Albrecht
08/08/2023, 6:30 PMRyan Albrecht
08/08/2023, 6:30 PMRyan Albrecht
08/08/2023, 6:32 PMid but you can specify the primary key by adding keyProperty and keyColumnleftbower
08/08/2023, 6:35 PMvar sql = "Select 1 from #validationData.table# where #validationData.column# = :name";leftbower
08/08/2023, 6:36 PMRyan Albrecht
08/08/2023, 6:37 PMRyan Albrecht
08/08/2023, 6:39 PMRyan Albrecht
08/08/2023, 6:40 PMidRyan Albrecht
08/08/2023, 6:44 PMleftbower
08/08/2023, 6:46 PMid, but ok... so as to my original question: it appears that an "id" property is a requirement? and/or a diff primary key needs to be passed in. That works now, thank you.leftbower
08/08/2023, 6:47 PMPatrick
08/08/2023, 6:47 PMid then just define it as Ryan is saying with those properties.Patrick
08/08/2023, 6:47 PMleftbower
08/08/2023, 6:50 PMRyan Albrecht
08/08/2023, 6:53 PMid property is not specifically required but a property that defines your primary key is. By default the unique validator will assume it is called id . If it is different you can specify this in the validation declaration eg.
this.constraints = {
team_name: {
unique = {
table : "team",
column : "name",
//the unique validator will call getTeamId() on your object
keyProperty: 'teamId',
//the unique validator will add the sql - 'and teamId <> :id'
keyColumn: 'teamId'
}
},
};Ryan Albrecht
08/08/2023, 6:54 PMPatrick
08/08/2023, 6:56 PMleftbower
08/08/2023, 6:56 PMteam_name and the PK is teamID... 👀Ryan Albrecht
08/08/2023, 6:56 PMleftbower
08/08/2023, 7:14 PMunique validator? I've tried adding a uniqueMessage in both the team_name parent struct and the unique struct, but it's not picked up in either? Other custom messages work fine.Ryan Albrecht
08/08/2023, 7:15 PMRyan Albrecht
08/08/2023, 7:15 PMleftbower
08/08/2023, 7:17 PMRyan Albrecht
08/08/2023, 8:00 PMRyan Albrecht
08/08/2023, 8:02 PMRyan Albrecht
08/08/2023, 8:03 PMRyan Albrecht
08/08/2023, 8:46 PMPatrick
08/08/2023, 8:49 PM"team_name": . I usually am just using cborm for this stuff not sure about the method for just cbvalidation tool.Patrick
08/08/2023, 8:50 PMwil-shiftinsert
08/08/2023, 8:56 PMRyan Albrecht
08/08/2023, 8:57 PMRyan Albrecht
08/08/2023, 8:58 PMwil-shiftinsert
08/08/2023, 9:00 PMwil-shiftinsert
08/08/2023, 9:03 PMwil-shiftinsert
08/08/2023, 9:04 PM