Refactored validation
This commit is contained in:
1 parent
fe4a39803c
commit
7be3a1b5bc
29 files changed
+696
-545
No files matched your search
@@ -68,7 +68,7 @@ namespace domain {
|
||||
errors.emplace_back(Action::ERROR, message);
|
||||
} else if (count > bus.getCount().second) {
|
||||
auto message = populateMessage(
|
||||
"Previše instanci sabirnice '{busName}' dozvoljeno najviše {max}, pronašeno {count}", context);
|
||||
"Previše instanci sabirnice '{busName}' dozvoljeno najviše {max}, pronađeno {count}", context);
|
||||
errors.emplace_back(Action::ERROR, message);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -197,4 +197,31 @@ namespace domain {
|
||||
return val;
|
||||
}
|
||||
|
||||
bool Value::equals(Value value) {
|
||||
if (value.getType() == type) {
|
||||
switch (type) {
|
||||
case INT:
|
||||
return value.asInt() == intValue;
|
||||
case STRING:
|
||||
return value.asString() == stringValue;
|
||||
case NIL:
|
||||
case UNDEFINED:
|
||||
return true;
|
||||
case WIRE_REFERENCE:
|
||||
case ATTRIBUTE_REFERENCE:
|
||||
case ADDRESS_SPACE_REFERENCE:
|
||||
return value.asReference() == reference;
|
||||
case MEMORY_REFERENCE:
|
||||
return value.asMemoryReference() == memoryReference;
|
||||
case MEMORY:
|
||||
return value.asMemory() == memory;
|
||||
case BOOL:
|
||||
return value.asBool() == boolValue;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
} // namespace domain
|
||||
+1
-26
@@ -43,32 +43,7 @@ namespace domain {
|
||||
|
||||
Value() = default;
|
||||
|
||||
bool equals(Value value) {
|
||||
if (value.getType() == type) {
|
||||
switch (type) {
|
||||
case INT:
|
||||
return value.asInt() == intValue;
|
||||
case STRING:
|
||||
return value.asString() == stringValue;
|
||||
case NIL:
|
||||
case UNDEFINED:
|
||||
return true;
|
||||
case WIRE_REFERENCE:
|
||||
case ATTRIBUTE_REFERENCE:
|
||||
case ADDRESS_SPACE_REFERENCE:
|
||||
return value.asReference() == reference;
|
||||
case MEMORY_REFERENCE:
|
||||
return value.asMemoryReference() == memoryReference;
|
||||
case MEMORY:
|
||||
return value.asMemory() == memory;
|
||||
case BOOL:
|
||||
return value.asBool() == boolValue;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
bool equals(Value value);
|
||||
|
||||
std::string string();
|
||||
|
||||
|
||||
Reference in new issue
Block a user