Skip to main content


Formidable includes a variety of "helper" functions. Many of these functions are used by the framework itself; however, you are free to use them in your own applications if you find them convenient.


To use a formidable helper function, you need to import it from @formidablejs/framework/lib/Support/Helpers:

import { slug } from '@formidablejs/framework/lib/Support/Helpers'

slug('Donald Pakkies') # donald-pakkies

Available Functions

Arrays & Objects


The asObject function, converts a custom object into a JavaScript object:

const object = asObject(customObject)


The dotNotation function turns an object into a single level value that uses "dot" notation to indicate depth:

const object = {
app: {
name: 'Formidable'

const appName = dotNotation(object, 'app.locale')

You may also use dot, an alias of dotNotation:

const object = {
app: {
name: 'Formidable'

const appName = dot(object, 'app.locale')


The without helper removes specified data from the given object:

name: 'Donald',
city: 'East Rand'
}, ['city'])

# { name: 'Donald' }


The isArray helper checks if the given variable is a valid Array:

if isArray([])
# do something


The isBoolean helper checks if the given variable is a valid Boolean:

if isBoolean(variable)
# do something


The isClass helper checks if the given variable is a valid Class:

if isClass(variable)
# do something


The isFunction helper checks if the given variable is a valid Function:

if isFunction(variable)
# do something


The isNumber helper checks if the given variable is a valid Number:

if isNumber(variable)
# do something


The isObject helper checks if the given variable is a valid Object:

if isObject(variable)
# do something


The isString helper checks if the given variable is a valid String:

if isString(variable)
# do something


The toBoolean helper converts the given variable into a Boolean value:

toBoolean('true') # true

toBoolean(true) # true

toBoolean(1) # true


The wildcard helper checks if the given variable matches a wildcard:

wildcard('/user/*/edit', '/user/1/edit') # true

wildcard('/tasks/*', 'tasks/learn-imba') # true



The slug helper converts the given string into a slug:

slug('Hello world', '-') # hello-world


The strRandom helper generates a random string:

strRandom() # bfd809fc

# with custom length
strRandom(40) # 485f8c73737030df7872e2c3e5e2d3b0eb1d769f

Note, length must be divisible by 2.



The encrypt helper encrypts an object.

encrypt('Hello World') # f8867ec8f7960de147f4c2da37fe4b99


The decrypt helper decrypts an encrypted value.

decrypt('f8867ec8f7960de147f4c2da37fe4b99') # Hello World



The now helper returns the current timestamp instance for Database queries:



The expiresIn helper creates an expiration date for Redis:

expiresIn('2 minutes')

expiresIn('1 hour')

expiresIn('3 days')


The config function gets the value of a configuration variable. The configuration values are accessed using "dot" syntax, which includes the name of the file and the option you wish to access. A default value may be specified and is returned if the configuration option does not exist:

const appName = config('')

const appName = config('', 'Something else')


The env function retrieves the value of an environment variable or returns a default value:

const appUrl = env('APP_URL')

const appUrl = env('APP_URL', 'http://localhost:3000')


The response function returns a response object to the client:

response('Hello', 200)

message: 'Hello'



The view function returns a view response to the client:

view(Profile, { user }, 200)

tap & multitap

The tap function accepts two arguments: an arbitrary value and a callback. The value will be passed to the callback and then be returned by the tap function. The return value of the callback is irrelevant:

const user = tap User.forge!.first!, do(user) = 'Donald'!

If no callback is passed to the tap function, you may call any method on the given value. The return value of the method you call will always be value, regardless of what the method actually returns in its definition:

user = tap(user).save({
name: 'Donald'

You may also use the multitap function, this function allows you to access any method that's part of value by always returning value after you call a value method:

user = multitap(user)
.setLocation('East Rand')

In the example above, we have a untap method which we call at the end of our method calls, we do this so we can exit multitap.