MCPcopy Create free account
hub / github.com/TelegramMessenger/cocoon / get_boolean

Method get_boolean

runners/helpers/ValidateRequest.cpp:603–625  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

601 }
602
603 td::Result<bool> get_boolean() {
604 switch (mode) {
605 case Mode::Form:
606 return td::Status::Error(ton::ErrorCode::protoviolation, PSTRING() << path << " must be a boolean");
607 case Mode::Slice: {
608 auto R = td::to_integer_safe<td::int64>(field->value);
609 if (R.is_error()) {
610 return td::Status::Error(ton::ErrorCode::protoviolation, PSTRING() << path << " must be a boolean");
611 } else {
612 return (bool)R.move_as_ok();
613 }
614 }
615 case Mode::Json: {
616 auto e = obj;
617 if (!e || !e->is_boolean()) {
618 return td::Status::Error(ton::ErrorCode::protoviolation, PSTRING() << path << " must be a boolean");
619 }
620 return e->get<bool>();
621 }
622 default:
623 return td::Status::Error(ton::ErrorCode::protoviolation, PSTRING() << path << " must be an integer");
624 }
625 }
626
627 bool is_double() {
628 switch (mode) {

Callers

nothing calls this directly

Calls 1

is_booleanMethod · 0.45

Tested by

no test coverage detected