Skip to content

Should check for 'undefined' or null parameter values #85

@KrishnaPG

Description

@KrishnaPG

All methods should check validity of parameters.

For example, https://github.com/HubSpot/humanize/blob/master/src/humanize.js#L281

truncate(str, length = 100, ending = '...')
{
   if (str && str.length > length) ...
}

This is useful when calling Humanize.truncate directly from data received from db queries and other external entities. Validating parameters outside (before calling the methods of Humanize) is code redundancy and can be avoided if the library takes care of it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions