Skip to content

maxchou415/object-property-validator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Object Property Validator

Accept Property Checker

Define an array of accept elements, such as ['name', 'email'], and send them to the function - accepted(), and also send the object that you want to check, such as requesting body.

For example:

    const acceptedFields = ['name', 'email']
    try {
        accepted(acceptedFields, req.body)
    } catch (error) {
        return error
    }

This will returns a filtered object as you want.

Require Property Checker

Define an array of require elements, such as ['name', 'email'], and send them to the function - required(), and also send the object that you want to check, such as requesting body.

For example:

    const requiredFields = ['name', 'email']
    try {
        required(requiredFields, req.body)
    } catch (error) {
        // It will also return detailed lost elements.
        return error
    }

About

A collection of utils to provide a easy way of checking unexpected object property missing or unaccepted object property by preset dataset.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors