FOSSredder 0.5.0
Loading...
Searching...
No Matches
Year.cpp
Go to the documentation of this file.
1
5
7
8namespace core::domain {
9
10namespace {
11
12constexpr int kMinValue = 1;
13constexpr int kMaxValue = 9999;
14
15} // namespace
16
18 : value_(normalize(value)) {}
19
20int Year::value() const noexcept { return value_; }
21
22constexpr int Year::minValue() noexcept {
23 return kMinValue;
24}
25
26constexpr int Year::maxValue() noexcept {
27 return kMaxValue;
28}
29
30bool Year::isValid(int value) noexcept {
31 return value >= minValue() && value <= maxValue();
32}
33
34int Year::normalize(int value) noexcept {
35 return isValid(value) ? value : 0;
36}
37
38bool Year::empty() const noexcept {
39 return value_ == 0;
40}
41
42} // namespace core::domain
Value object for annual year validation.
bool empty() const noexcept
Checks whether the stored value is empty.
Definition Year.cpp:38
static bool isValid(int value) noexcept
Checks whether a raw year is valid.
Definition Year.cpp:30
static constexpr int maxValue() noexcept
Returns the maximum supported year.
Definition Year.cpp:26
static constexpr int minValue() noexcept
Returns the minimum supported year.
Definition Year.cpp:22
int value() const noexcept
Definition Year.cpp:20
static int normalize(int value) noexcept
Normalizes a raw year value.
Definition Year.cpp:34