Non-empty string
Project description
nonemptystr
Non-empty string.
Usage
from nonemptystr import EmptyString, nonemptystr
name: nonemptystr = nonemptystr("John")
try:
name = nonemptystr("")
except EmptyString:
print("The name is empty.")
... with pydantic
from nonemptystr import nonemptystr
from pydantic import BaseModel, ValidationError
class Request(BaseModel):
user_id: nonemptystr
try:
request = Request.parse_obj({"user_id": ""})
print(f"user_id: {request.user_id}")
except ValidationError:
print("user_id is empty")
Caveat: Currently it does NOT seem to work properly
when it is used with field constraints of pydantic
as: user_id: nonemptystr = Field(..., max_length=10)
(#1)
API
Module nonemptystr
class nonemptystr(obj: object)
Subclass of str
.
Raise EmptyString
exception if str(obj)
is empty string.
class EmptyString
Subclass of ValueError
.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
nonemptystr-0.2.1.tar.gz
(3.1 kB
view hashes)
Built Distribution
Close
Hashes for nonemptystr-0.2.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0776e46310fddcbe24533a8daaec4b5ee5820949ace0b780c78bb96fc1c99d2a |
|
MD5 | af0edfab9c60857cb289c04ea20a3d73 |
|
BLAKE2b-256 | 2b8ae59058822d2d983f2428d6485125b93f3b83c965ea1488beda41f9a171e3 |