Skip to content

Commit

Permalink
Flow coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
yoiang committed Jan 22, 2018
1 parent 271852b commit 85a006c
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions lib/types.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
/* @flow */

export type ValueDescription = {
value: any,
typeof: string
}

export type ValidationResult = ValueDescription | false;

// Returns if a value is a string
export const isString = (value) => {
export const isString = (value: any): ValidationResult => {
if (typeof value === 'string' || value instanceof String) {
return {
value,
Expand All @@ -10,7 +19,7 @@ export const isString = (value) => {
}

// Returns if a value is really a number
export const isNumber = (value) => {
export const isNumber = (value: any): ValidationResult => {
if (typeof value === 'number' && isFinite(value)) {
return {
value,
Expand All @@ -21,7 +30,7 @@ export const isNumber = (value) => {
}

// Returns if a value is an array
export const isArray = (value) => {
export const isArray = (value: any): ValidationResult => {
if (value && typeof value === 'object' && value.constructor === Array) {
return {
value,
Expand All @@ -32,7 +41,7 @@ export const isArray = (value) => {
}

// Returns if a value is an object
export const isObject = (value) => {
export const isObject = (value: any): ValidationResult => {
if (value && typeof value === 'object' && value.constructor === Object) {
return {
value,
Expand All @@ -43,7 +52,7 @@ export const isObject = (value) => {
}

// Returns if a value is null
export const isNull = (value) => {
export const isNull = (value: any): ValidationResult => {
if (value === null) {
return {
value,
Expand All @@ -54,7 +63,7 @@ export const isNull = (value) => {
}

// Returns if a value is undefined
export const isUndefined = (value) => {
export const isUndefined = (value: any): ValidationResult => {
if (typeof value === 'undefined') {
return {
value,
Expand All @@ -65,7 +74,7 @@ export const isUndefined = (value) => {
}

// Returns if a value is a boolean
export const isBoolean = (value) => {
export const isBoolean = (value: any): ValidationResult => {
if (typeof value === 'boolean') {
return {
value,
Expand All @@ -76,7 +85,7 @@ export const isBoolean = (value) => {
}

// Returns if value is a date object
export const isDate = (value) => {
export const isDate = (value: any): ValidationResult => {
if (value instanceof Date) {
return {
value,
Expand Down

0 comments on commit 85a006c

Please sign in to comment.