Description
The current validation error message: 'Not a valid URL.'
is not descriptive enough to help the user, especially when they are passing a value that would appear to be a valid URL to most people, such as a docker hostname: http://test-url:8001
Sample code:
from marshmallow import Schema, fields
class TestSchema(Schema):
url = fields.URL(required=True)
TestSchema().load({"url": "http://192.168"}) // this works
TestSchema().load({"url": "http://test-url"}) // this doesn't work
TestSchema().load({"url": "derp"}) // and this has the same error message as http://test-url
This is because fields.URL has a default: require_tld=True
, for require_tld: Whether to reject non-FQDN hostnames.
FQDN = fully-qualified domain name. i.e. http://server1.example.com
is a FQDN, http://server1
is not.
Suggestion: error message should be more descriptive when require_tld is True, and validation fails FQDN requirement.
Metadata
Metadata
Assignees
Labels
No labels