void FaceUpdateCommand::validateRequest(const ControlParameters& parameters) const { this->ControlCommand::validateRequest(parameters); if (parameters.hasFlags() != parameters.hasMask()) { BOOST_THROW_EXCEPTION(ArgumentError("Flags must be accompanied by Mask")); } }
void ControlCommand::FieldValidator::validate(const ControlParameters& parameters) const { const std::vector<bool>& presentFields = parameters.getPresentFields(); for (size_t i = 0; i < CONTROL_PARAMETER_UBOUND; ++i) { bool isPresent = presentFields[i]; if (m_required[i]) { if (!isPresent) { BOOST_THROW_EXCEPTION(ArgumentError(CONTROL_PARAMETER_FIELD[i] + " is required but missing")); } } else if (isPresent && !m_optional[i]) { BOOST_THROW_EXCEPTION(ArgumentError(CONTROL_PARAMETER_FIELD[i] + " is forbidden but present")); } } if (m_optional[CONTROL_PARAMETER_FLAGS] && m_optional[CONTROL_PARAMETER_MASK]) { if (parameters.hasFlags() != parameters.hasMask()) { BOOST_THROW_EXCEPTION(ArgumentError("Flags must be accompanied by Mask")); } } }