-
Notifications
You must be signed in to change notification settings - Fork 1
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
Added formats for "empty" and "year" #2
Conversation
assert.equal(tr(TEST_OBJECT, TEST_NOT_EMPTY_FIELD_TRUE), true); | ||
assert.equal(tr(TEST_OBJECT, TEST_NOT_EMPTY_FIELD_FALSE), false); | ||
}); | ||
it('should return true/false when a test field is empty', function () { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this also work if emptyField: null/false/0?
What if emptyField isn't defined?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
emptyField is an arbitrary test field. If empty is not defined, the test will not be triggered.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ha true, my bad
return testValue is objectValue | ||
objectValue = JSON.stringify(objectValue) # match in stringified arrays and objects too | ||
re = RegExp testValue, "im" | ||
match = re.test objectValue |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just do return re.test objectValue
no need to store match and return it right after
return (objectValue is null) or (objectValue is 0) or (objectValue.length is 0) or (Object.keys(objectValue).length is 0) | ||
|
||
else #return true if objectValue is not empty | ||
return not ((objectValue is null) or (objectValue is 0) or (objectValue.length is 0) or (Object.keys(objectValue).length is 0)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can merge this and the above if statment by doing checking if isEmpty. Then return if shouldBeEmpty return isEmpty else return not isEmpty
Added formats for "empty" and "year"
No description provided.