This package has been deprecated

Author message:

Package no longer suported. Use at your own risk.

check-if

1.0.0 • Public • Published

check-if

github license npm version tested with jest

Client input validation library.

Usage

Install module

npm install --save check-if

yarn add check-if

Sample

const checkIf = require('check-if')
 
// [your code here...]
 
if (!checkIf.isShortDate('2043-01-01')) {
  // Logic to handle invalid input goes here
}

Functions

Function Description
areInSyncFirestoreTimestamps(timeA, timeB) Returns false if:
- any of the inputs is not a valid firebase.Firestore.Timestamp
- the times don't match
containsExactProperties(object, properties) Returns false if the properties listed in properties do not match the properties contained in object.
containsUpdatedProperties(objectUpdates, originalObject) Returns false if any of the properties in the objectUpdates has the same value in originalObject. Only does a shallow comparison (does not works for objects that does not contain nested objects/properties).
isFirestoreId(id) Returns false if:
- not a valid Firestore id (20 characters a-z, A-Z, and 0-9)
isFirestoreTimestamp(timestamp) Returns false if:
- not a valid firebase.firestore.Timestamp (contains toDate and toMillis functions)
isNonDeletedObject(object) Returns false if:
- object is not of type object
- object.deleted or object.del is defined and set to true
isNonEmptyFirestoreDocumentSnapshot(documentSnapshot) Returns false if:
- documentSnapshot is not of type object
- documentSnapshot.exists is undefined or false
isShortDate(value) Expects a date with the format (YYYY-MM-DD). Returns false if:
- value is not a string with exactly 10 characters
- value can not be parsed by new Date(value)
isTrimmedNonEmptyString(value) Returns false if:
- value is not a string
- value is not trimmed
- string is empty

Package Sidebar

Install

npm i check-if

Weekly Downloads

3

Version

1.0.0

License

MIT

Unpacked Size

135 kB

Total Files

53

Last publish

Collaborators

  • ericvera