Skip to content
This repository has been archived by the owner on Sep 6, 2021. It is now read-only.

Adds additional validation used primarily in brackets-registry #3384

Merged
merged 4 commits into from
Apr 9, 2013

Conversation

dangoor
Copy link
Contributor

@dangoor dangoor commented Apr 9, 2013

  • confirm that brackets.engine is a valid semver range
  • normalizes author and contributors to always be objects
  • allows rejection based on a word list

@ghost ghost assigned njx Apr 9, 2013
@dangoor
Copy link
Contributor Author

dangoor commented Apr 9, 2013

to @njx

var result = {
name: parts[1]
};
if (parts[2]) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we were in optimize-the-heck-out-of-our-JS land I would suggest getting rid of the ifs and just putting email: parts[2], url: parts[3] in the constructed object, since by definition they'd be undefined anyway if there was no match. But the ex-non-JS guy in me likes the clarity :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought of that, but I didn't like how the resulting object actually had email and url keys even if those were undefined.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, that shows my JS ignorance. I just assumed it wouldn't set the key. Learn something new every day.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I actually had to fire up node this morning to confirm that this is how it works...

> foo = { name: "Hi there", email: undefined }
{ name: 'Hi there', email: undefined }
> Object.keys(foo)
[ 'name', 'email' ]

@njx
Copy link
Contributor

njx commented Apr 9, 2013

Looks good. I'm looking forward to us checking a list of naughty words into the Brackets codebase.

njx added a commit that referenced this pull request Apr 9, 2013
Adds additional validation used primarily in brackets-registry
@njx njx merged commit 43c4f62 into master Apr 9, 2013
@njx njx deleted the dangoor/more-validation branch April 9, 2013 16:52
@njx
Copy link
Contributor

njx commented Apr 9, 2013

Feel free to push a new commit to master directly with the comment fixes.

@dangoor
Copy link
Contributor Author

dangoor commented Apr 9, 2013

OK, will update the comments. I thought JSDoc was supposed to grab the param name from the function arguments, but you're right that it doesn't.

I'm actually not planning to check naughty words in. I was thinking of just making disallowed words a config option in brackets-registry :)

@@ -317,6 +317,8 @@ define({
"BAD_PACKAGE_NAME" : "{0} is an invalid package name.",
"MISSING_PACKAGE_VERSION" : "The package.json file doesn't specify a package version.",
"INVALID_VERSION_NUMBER" : "The package version number ({0}) is invalid.",
"INVALID_BRACKETS_VERSION" : "The Brackets compatibility string {{0}} is invalid.",
"DISALLOWED_WORDS" : "The words {{1}} are not allowed in the {{1}} field.",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dangoor Maybe this should be The words {{0}} are not allowed in the {{1}} field. ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, it's probably the other way around :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, Chema. Thanks! (and yes, it should be {{1}} and {{0}}).

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants