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

Post check() allows empty strings #278

Open
kylefox opened this issue Jan 3, 2016 · 0 comments
Open

Post check() allows empty strings #278

kylefox opened this issue Jan 3, 2016 · 0 comments

Comments

@kylefox
Copy link

kylefox commented Jan 3, 2016

In Creating Posts the following code is added to lib/collections/posts.js to validate postAttributes:

check(postAttributes, {
  title: String,
  url: String
});

However, this provides no enforcement on string length and thus allows the user to submit an empty form, creating a document with empty attributes.

According to the Match Patterns documentation, the correct approach is to use Match.Where(condition) to ensure the string is not empty:

NonEmptyString = Match.Where(function (x) {
  check(x, String);
  return x.length > 0;
});

check(postAttributes, {
  title: NonEmptyString,
  url: NonEmptyString
});
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

No branches or pull requests

1 participant