Skip to content

A simple normalisation library, intended to transform user generated results with possible errors.

License

Notifications You must be signed in to change notification settings

femto-apps/lib-normaliser

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

lib-normaliser

A simple normalisation library, intended to transform user generated results with possible errors.

Usage

const { normalise } = require('@femto-apps/normaliser')

const normaliser = {
    name: name => {
        if (name.length < 10) {
            return [['Name too short']]
        }
        
        return [null, name.toTitleCase()]
    }
}

{
    const { name, error } = normalise(normaliser, { name: 'bad_user' })
    // error: { name: ['Name too short'] } 
    // name: undefined
}

{
    const { name, error } = normalise(normaliser, { name: 'a_very_good_user' })
    // error: undefined
    // name: A_very_good_user
}

About

A simple normalisation library, intended to transform user generated results with possible errors.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published