Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce @Pal.omit attribute #235

Merged
merged 4 commits into from
Sep 23, 2021
Merged

Introduce @Pal.omit attribute #235

merged 4 commits into from
Sep 23, 2021

Conversation

dimaip
Copy link
Contributor

@dimaip dimaip commented Sep 23, 2021

Resolves: #234

Put this kind of comment to hide a field from the generated types:

model User {
  /// @Pal.omit([input,output])
  password      String?
  /// @Pal.omit
  email             String?
}

Documentation: paljs/docs#8

@AhmedElywa
Copy link
Collaborator

private static checkOmit(docs?: string, name?: 'input' | 'output') {
    const value = docs?.match(/@Pal.omit\(\[(.*?)\]\)/);
    if (value && name) {
      const asArray = value[1]
        .replace(/ /g, '')
        .split(',')
        .filter((v) => v);
      return asArray.includes(name);
    }
    return false;
  }

@AhmedElywa AhmedElywa merged commit 339252d into paljs:main Sep 23, 2021
@dimaip dimaip deleted the omit branch September 23, 2021 15:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Securing inverse relations
2 participants