Skip to content

.with and .without accept an array of args as well #107

@dacbd

Description

@dacbd

I made a boo boo and passed an array to these methods instead of calling the method with them as individual parameters, fixed my mistake after realizing I was doing it wrong via the crypt 400 response and second look at the readme, but was wondering if you would be open to that as an acceptable form of input, for example:

validate: {
    payload: {
        latitude: Hapi.types.Number()
            .min(-90).max(90)
            .optional()
            .with(['longitude','radius'])
        longitude: Hapi.types.Number()
            .min(-180).max(180)
            .optional()
            .with(['latitude', 'radius'])
        radius: Hapi.types.Number()
            .min(0)
            .optional()
            .with(['latitude', 'longitude'])
    }
}

instead of:

validate: {
    payload: {
        latitude: Hapi.types.Number()
            .min(-90).max(90)
            .optional()
            .with('longitude','radius')
        longitude: Hapi.types.Number()
            .min(-180).max(180)
            .optional()
            .with('latitude', 'radius')
        radius: Hapi.types.Number()
            .min(0)
            .optional()
            .with('latitude', 'longitude')
    }
}

If you don't like the idea then we can close the issue otherwise I'll send a pull request later.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions