Skip to content

Commit

Permalink
fix array check
Browse files Browse the repository at this point in the history
  • Loading branch information
ymc9 committed Jun 14, 2024
1 parent b4e028c commit 1b9e99c
Showing 1 changed file with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
DataModelAttribute,
Expression,
ExpressionType,
isArrayExpr,
isDataModel,
isDataModelAttribute,
isDataModelField,
Expand Down Expand Up @@ -284,9 +285,18 @@ export default class ExpressionValidator implements AstValidator<Expression> {
return findUpAst(node, (n) => isDataModelAttribute(n) && n.decl.$refText === '@@validate');
}

private isNotModelFieldExpr(expr: Expression) {
private isNotModelFieldExpr(expr: Expression): boolean {
return (
isLiteralExpr(expr) || isEnumFieldReference(expr) || isNullExpr(expr) || this.isAuthOrAuthMemberAccess(expr)
// literal
isLiteralExpr(expr) ||
// enum field
isEnumFieldReference(expr) ||
// null
isNullExpr(expr) ||
// `auth()` access
this.isAuthOrAuthMemberAccess(expr) ||
// array
(isArrayExpr(expr) && expr.items.every((item) => this.isNotModelFieldExpr(item)))
);
}

Expand Down

0 comments on commit 1b9e99c

Please sign in to comment.