Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

check-if

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

check-if

Input validation for Apollo Server.

  • 0.4.4
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
8
increased by60%
Maintainers
1
Weekly downloads
 
Created
Source

check-if

github license npm version tested with jest

Client input validation library.

Usage

Install module

npm install --save check-if

Sample

const checkIf = require('check-if')

// [your code here...]

if (!checkIf.isDateInMs('2043-01-01')) {
  // Logic to handle invalid input goes here
}

Functions

FunctionsDescription
areInSync(localLastUpdated, serverLastUpdated)Returns false if:
- any of the inputs is not a valid Date
- The times don't match
containsProperties(object, properties)Returns false if any of the property names listed in properties are not in object
containsUpdatedProperties(objectUpdates, originalObject)Returns false if any of the properties in the objectUpdates has the same value in originalObject. Change validation uses == as opposed to === and only works for objects that does not contain nested objects.
isDateInMs(value)Returns false if:
- value is not a number
- value can not be parsed by new Date(value)
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 Firestore Timestamp (contains toDate and toMillis functions)
isNonDeletedObject(object)Returns false if:
- object is not of type object
- object.deleted is defined and set to true
isNonEmptyObject(object)Returns false if:
- object is not of type object
- object is empty
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

Keywords

FAQs

Package last updated on 20 Aug 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc