expresso
  • Get Started
    • 👋Welcome!
    • ⚡Quick Start
  • Expresso Library
    • 📖Introduction
    • ⚛️expresso-core
      • Currency
      • Random String
      • Formatter
      • File
      • Phone
    • ⚓expresso-hooks
      • Multer
      • Token
      • OTP
    • 🚀expresso-provider
      • FCM
      • SMTP
      • Redis
      • Storage
    • 🔗expresso-query
      • TypeORM
      • Sequelize
Powered by GitBook
On this page
  • Format ms 1d ( 1 day )
  • format ms 5m ( 5 minute )
  • isNumeric value
  • Validate Number value
  • Validate Boolean value
  • Validate Empty value
  1. Expresso Library
  2. expresso-core

Formatter

library formatter to simplify validate and format value

Using commonjs

const { ms } = require('expresso-core')

Using ES6

import { ms } from 'expresso-core'

Format ms 1d ( 1 day )

import { ms } from 'expresso-core'

const result = ms('1d')

console.log(result)

// output:
86400000

format ms 5m ( 5 minute )

import { ms } from 'expresso-core'

const result = ms('5m')

console.log(result)

// output:
300000

isNumeric value

import { isNumeric } from 'expresso-core'

const result = isNumeric('10')

console.log(result)

// output:
10

Validate Number value

import { validateNumber } from 'expresso-core'

const result = validateNumber('10')

console.log(result)

// output:
10

// Wrong Value
const wrongResult = validateNumber(false)

console.log(result)

// output:
0

Validate Boolean value

import { validateBoolean } from 'expresso-core'

const result = validateBoolean('true')

console.log(result)

// output:
true

// Wrong Result
const result = validateBoolean(null)

console.log(result)

// output:
false

Validate Empty value

import { validateEmpty } from 'expresso-core'

const result = validateEmpty('any value')

console.log(result)

// output:
'any value'

// Wrong Result
const result = validateEmpty(null)

console.log(result)

// output:
null
PreviousRandom StringNextFile

Last updated 1 year ago

⚛️