Skip to content

Instantly share code, notes, and snippets.

@richardkundl
Last active December 20, 2022 20:06
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save richardkundl/4c94143d86b53abdc3f4 to your computer and use it in GitHub Desktop.
Save richardkundl/4c94143d86b53abdc3f4 to your computer and use it in GitHub Desktop.
Javascript is empty function
// Current value is empty
this.isEmpty = function(value){
return value == null // NULL value
|| value == undefined // undefined
|| value == 'undefined' // undefined
|| value.length == 0 // Array is empty
|| value == '00000000-0000-0000-0000-000000000000' // Guid empty
|| ((value instanceof Date && !isNaN(value.valueOf())) // Validate DateTime value and check min-max value
&& ((value <= new Date(1753, 01, 01)) // SQL DateTime minimum value
|| (value >= new Date(9999, 12, 31, 23, 59, 59, 999))) // SQL DateTime maximum value
);
}
@richardkundl
Copy link
Author

add SQL DateTime check

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment