Python Value-Objects
A collection of Value Objects to save time by generalizing types and format validations.
- Value-objects
Value-objects
Numeric value-objects
Int
Integer numbers without a fractional component that don't support decimal points.
from pyvalueobjects import Int
# Creation
my_integer = Int(9)
# Getting raw value
my_integer.value() # returns -> 9
Nullable Int
Integer numbers and None.
from pyvalueobjects import NullableInt
# Creation
my_integer = NullableInt(9)
# Creating from None
my_nullable_integer = NullableInt(None)
# Getting raw value
my_integer.value() # returns -> 9
my_nullable_integer.value() # returns -> None
Positive Int
from pyvalueobjects import PositiveInt
# Creation
my_integer = PositiveInt(9)
# Getting raw value
my_integer.value() # returns -> 9
Nullable Positive Int
from pyvalueobjects import NullablePositiveInt
# Creation
my_integer = NullablePositiveInt(9)
# Creating from None
my_nullable_integer = NullablePositiveInt(None)
# Getting raw value
my_integer.value() # returns -> 9
my_nullable_integer.value() # returns -> None
Positive Or Zero Int
from pyvalueobjects import PositiveOrZeroInt
# Creation
my_integer = PositiveOrZeroInt(9)
# Getting raw value
my_integer.value() # returns -> 9
Nullable Positive Or Zero Int
from pyvalueobjects import NullablePositiveOrZeroInt
# Creation
my_integer = NullablePositiveOrZeroInt(9)
# Creating from None
my_nullable_integer = NullablePositiveOrZeroInt(None)
# Getting raw value
my_integer.value() # returns -> 9
my_nullable_integer.value() # returns -> None
Negative Int
from pyvalueobjects import NegativeInt
# Creation
my_integer = NegativeInt(-9)
# Getting raw value
my_integer.value() # returns -> -9
Nullable Negative Int
from pyvalueobjects import NullableNegativeInt
# Creation
my_integer = NullableNegativeInt(-9)
# Creating from None
my_nullable_integer = NullableNegativeInt(None)
# Getting raw value
my_integer.value() # returns -> -9
my_nullable_integer.value() # returns -> None
Negative Or Zero Int
from pyvalueobjects import NegativeOrZeroInt
# Creation
my_integer = NegativeOrZeroInt(-9)
# Getting raw value
my_integer.value() # returns -> -9
Nullable Negative Or Zero Int
from pyvalueobjects import NullableNegativeOrZeroInt
# Creation
my_integer = NullableNegativeOrZeroInt(-9)
# Creating from None
my_nullable_integer = NullableNegativeOrZeroInt(None)
# Getting raw value
my_integer.value() # returns -> -9
my_nullable_integer.value() # returns -> None
String value-objects
String
from pyvalueobjects import String
# Creation
my_str = String('potato')
# Getting raw value
my_str.value() # returns -> 'potato'
Nullable String
from pyvalueobjects import NullableString
# Creation
my_str = NullableString('potato')
# Getting raw value
my_str.value() # returns -> 'potato'
# Creation
my_nullable_str = NullableString(None)
# Getting raw value
my_nullable_str.value() # returns -> None
Non Empty String
from pyvalueobjects import NonEmptyString
# Creation
my_str = NonEmptyString('potato')
# Getting raw value
my_str.value() # returns -> 'potato'
# Creation
my_str2 = NonEmptyString('') # raises error
Nullable non Empty String
from pyvalueobjects import NullableNonEmptyString
# Creation
my_str = NullableNonEmptyString('potato')
# Getting raw value
my_str.value() # returns -> 'potato'
# Creation
my_str2 = NullableNonEmptyString(None)
# Getting raw value
my_str2.value() # returns -> None
# Creation
my_str3 = NullableNonEmptyString('') # raises error
Uuid4
from pyvalueobjects import Uuid4
# Creation
my_uuid4 = Uuid4('6c7add12-bf35-459e-a6c5-3178a2a33011')
# Getting raw value
my_uuid4.value() # returns -> '6c7add12-bf35-459e-a6c5-3178a2a33011'
Nullable Uuid4
from pyvalueobjects import NullableUuid4
# Creation
my_uuid4 = NullableUuid4('6c7add12-bf35-459e-a6c5-3178a2a33011')
my_null_uuid4 = NullableUuid4(None)
# Getting raw value
my_uuid4.value() # returns -> '6c7add12-bf35-459e-a6c5-3178a2a33011'
my_null_uuid4.value() # returns -> 'None'
Date value-objects
ISO Date
from pyvalueobjects import IsoDate
# Creation
my_date = IsoDate('2023-08-15T04:55:12.076Z')
# Getting raw value
my_date.value() # returns -> '2023-08-15T04:55:12.076Z'
Data structures value-objects
ArrayList
from pyvalueobjects import ArrayList
from pyvalueobjects import Int
# Creation
my_int_array = ArrayList(Int)([39])
# Getting raw value
my_int_array.value() # returns -> [39]
Nullable ArrayList
from pyvalueobjects import ArrayList
from pyvalueobjects import Int
# Creation
my_int_array = ArrayList(Int)([39])
my_null_array = ArrayList(Int)(None)
# Getting raw value
my_int_array.value() # returns -> [39]
my_null_array.value() # returns -> None
Security value-objects
CVE
from pyvalueobjects import Cve
# Creation
my_cve = Cve('CVE-2014-9418')
# Getting raw value
my_cve.value() # returns -> 'CVE-2014-9418'
Nullable CVE
from pyvalueobjects import NullableCve
# Creation
my_cve = NullableCve('CVE-2014-9418')
my_null_cve = NullableCve(None)
# Getting raw value
my_cve.value() # returns -> 'CVE-2014-9418'
my_null_cve.value() # returns -> None
CPE
from pyvalueobjects import Cpe
# Creation
my_cpe = Cpe('cpe:/a:openjdk:openjdk:8u282')
# Getting raw value
my_cpe.value() # returns -> 'cpe:/a:openjdk:openjdk:8u282'
Nullable CPE
from pyvalueobjects import NullableCpe
# Creation
my_cpe = NullableCpe('cpe:/a:openjdk:openjdk:8u282')
my_null_cpe = NullableCpe(None)
# Getting raw value
my_cpe.value() # returns -> 'cpe:/a:openjdk:openjdk:8u282'
my_null_cpe.value() # returns -> None
Metadata
Release files for pyvalueobjects 0.28.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pyvalueobjects-0.28.1.tar.gz | 8.3 kB | Without provenance | Details for pyvalueobjects-0.28.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pyvalueobjects-0.28.1-py3-none-any.whl | Python 3 | none | any | Details for pyvalueobjects-0.28.1-py3-none-any.whl |
Total release size: 22.8 kB
Release files / pyvalueobjects-0.28.1.tar.gz
| Download URL | pyvalueobjects-0.28.1.tar.gz |
|---|---|
| Size | 8.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
199e4013f08e9a7434c6b371f74c61b09daa0d235223d9d927737fc9785850a8
|
|
BLAKE2b-256 checksum How to use checksums |
7991fc54f350ecb31f75a8e1fbc6c5ba4235c9d53e123a1d9a4d7bd022edec5c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.7
|
Release files / pyvalueobjects-0.28.1-py3-none-any.whl
| Download URL | pyvalueobjects-0.28.1-py3-none-any.whl |
|---|---|
| Size | 14.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b155dad1b670aff1852f83ba11ca91b09d2098c1b214282d08156144ae59e2b0
|
|
BLAKE2b-256 checksum How to use checksums |
4334c494f39ac8e23d797c23bc221800d8142bfeba754fca1f9bd2aaba077ec9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.7
|
Security for pyvalueobjects 0.28.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.