hapijs / validate Goto Github PK
View Code? Open in Web Editor NEWhapi core internal validation support
License: Other
hapi core internal validation support
License: Other
Hey folks, we're seeing an interesting error when we migrated to Hapi 20. When we start a Hapi server on a docker host for example, using
this.server = Hapi.server({
port: this.options.port,
host: this.options.host
});
In this case the hostname is an autogenerated alphanumeric. If the hostname starts with a number, we see an error:
"host" must be a valid hostname
Here's my analysis, when the host is just the hostname without any domain and tld suffix, the number of segments here is 1
.
And in the loop, it gets tested if it is a tdlSegment. Since the hostname starts with a number, it fails here.
I believe if the number of segments is 1, we can assume that it is the hostname(machine name) and not a tdlSegment. In which case, we test it for a domainSegment.
Please let me know your thoughts.
Validate any FQDN that includes a trailing dot.
// Returns { error } as [Error [ValidationError]: "value" must be a valid hostname]
Validate.string().hostname().validate('www.hapi.dev.');
Validate does not allow the FQDN with a trailing dot to pass validation. Validation fails with a ValidationError
"value" must be a valid hostname
.
I would expect the FQDN with a trailing dot to validate without error. It is also worth noting that node's server.listen()
does allow hostnames that include a trailing dot.
A note to the implementer: I believe trailing dots are only allowed for FQDNs, which means the input a. cannot be an IP address , and b. must have at least three segments. In other words 192.168.1.1.
is not valid and (edited: see comment below).hapi.dev.
is not valid (missing a hostname in the leftmost label)
As described in hapijs/joi#2411, the hapi ecosystem will no longer depend directly on joi (although it will continue to support joi schemas in route validations). In order to satisfy our internal validation needs we still need a validation library, though! Eran has culled the joi codebase to remove features that we have no need to maintain for our internal purposes, and that is what you find here.
The test suite is fully passing, but coverage for this module began at ~97% with ~150 uncovered lines of code. We would like to bring it up to 100% so that it is in line with our typical standards. This is a tracking issue for anyone interested in contributing to this module's coverage. We could use the help!
I will be posting updates here to the module's coverage. If you want to cover some specific lines, or the lines in a particular file, just post here so we can organize around each other. Make any PRs to the branch named initial-coverage
, and please prefer to add tests over adjusting the codebase.
This will be edited as PRs are merged in order to remain up-to-date.
There are15613012594604133201610 remaining lines to cover.
Coverage: 99.81% (10/5373)
[in-progress] lib/errors.js missing coverage on line(s): 55, 59, 60, 115, 116, 149
[in-progress] lib/modify.js missing coverage on line(s): 101, 168, 183, 184
Code coverage below threshold: 99.81 < 100
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.