@@ -290,11 +290,13 @@ export default class AttributeApplicationValidator implements AstValidator<Attri
290290 }
291291 }
292292
293- @check ( '@@unique' )
294293 @check ( '@@id' )
294+ @check ( '@@index' )
295+ @check ( '@@unique' )
295296 // @ts -expect-error
296- private _checkUnique ( attr : AttributeApplication , accept : ValidationAcceptor ) {
297+ private _checkConstraint ( attr : AttributeApplication , accept : ValidationAcceptor ) {
297298 const fields = attr . args [ 0 ] ?. value ;
299+ const attrName = attr . decl . ref ?. name ;
298300 if ( ! fields ) {
299301 accept ( 'error' , `expects an array of field references` , {
300302 node : attr . args [ 0 ] ! ,
@@ -303,7 +305,7 @@ export default class AttributeApplicationValidator implements AstValidator<Attri
303305 }
304306 if ( isArrayExpr ( fields ) ) {
305307 if ( fields . items . length === 0 ) {
306- accept ( 'error' , `\`@@unique \` expects at least one field reference` , { node : fields } ) ;
308+ accept ( 'error' , `\`${ attrName } \` expects at least one field reference` , { node : fields } ) ;
307309 return ;
308310 }
309311 fields . items . forEach ( ( item ) => {
@@ -321,7 +323,7 @@ export default class AttributeApplicationValidator implements AstValidator<Attri
321323 }
322324
323325 if ( item . target . ref . $container !== attr . $container && isDelegateModel ( item . target . ref . $container ) ) {
324- accept ( 'error' , `Cannot use fields inherited from a polymorphic base model in \`@@unique \`` , {
326+ accept ( 'error' , `Cannot use fields inherited from a polymorphic base model in \`${ attrName } \`` , {
325327 node : item ,
326328 } ) ;
327329 }
0 commit comments