Skip to content

Validate port numbers #1346

@sholladay

Description

@sholladay

I have this in a few places...

joi.validate(option, {
    port : joi.number().integer().min(0).max(65535)
});

Given that joi is most commonly used for servers (related: string().hostname()) and port numbers are a standardized and commonly used thing, I would prefer for this to be built in.

joi.validate(option, {
    port : joi.number().port()
});

Beyond the readability and succinctness of it, I like that this would free my apps from having the 65535 constant, which people sometimes ask me about.

Thoughts?

Metadata

Metadata

Assignees

Labels

featureNew functionality or improvement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions