Giter VIP home page Giter VIP logo

validate's People

Contributors

arb avatar artemysinitsa avatar bolajiolajide avatar briansorahan avatar cjihrig avatar cl-joshcole avatar dacbd avatar danielb2 avatar danielo515 avatar davidtpate avatar devinivy avatar evgenyorekhov avatar fluxsauce avatar geek avatar hueniverse avatar iamdoron avatar jarrodyellets avatar jaswilli avatar johnbrett avatar kanongil avatar lloydbenson avatar ludwikjaniuk avatar marsup avatar nlf avatar petreboy14 avatar rokoroku avatar shudrum avatar thegoleffect avatar westyler avatar yjh0502 avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

validate's Issues

Invalid host name error when it starts with a number

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.

string().hostname() does not allow FQDNs ending with a dot

Support plan

  • is this issue currently blocking your project? (yes/no): no
  • is this issue affecting a production system? (yes/no): no

Context

  • node version: v12+
  • module version with issue: v17
  • last module version without issue: unknown
  • environment (e.g. node, browser, native): node
  • used with (e.g. hapi application, another framework, standalone, ...): standalone
  • any other relevant information: This issue was originally reported by @kanongil in #19 (comment).

What are you trying to achieve or the steps to reproduce?

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.');

What was the result you got?

Validate does not allow the FQDN with a trailing dot to pass validation. Validation fails with a ValidationError "value" must be a valid hostname.

What result did you expect?

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 hapi.dev. is not valid (missing a hostname in the leftmost label) (edited: see comment below).

Bring initial coverage up to 100%

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.

Coverage report

This will be edited as PRs are merged in order to remain up-to-date.
There are 156 130 125 94 60 41 33 20 16 10 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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.