MCPcopy Create free account
hub / github.com/chirpstack/chirpstack / validate

Method validate

chirpstack/src/storage/tenant.rs:38–62  ·  view source on GitHub ↗
(&self)

Source from the content-addressed store, hash-verified

36
37impl Tenant {
38 fn validate(&self) -> Result<(), Error> {
39 if self.name.is_empty() {
40 return Err(Error::Validation("name is not set".into()));
41 }
42
43 let nw_prefixes = config::get().network.get_dev_addr_prefixes();
44 for prefix in self.dev_addr_prefixes.deref().iter().flatten() {
45 let mut is_valid = false;
46
47 for nw_prefix in &nw_prefixes {
48 if prefix.is_subset_of(nw_prefix) {
49 is_valid = true;
50 }
51 }
52
53 if !is_valid {
54 return Err(Error::Validation(format!(
55 "DevAddr prefix {} is not a subset of configured network DevAddr space",
56 prefix
57 )));
58 }
59 }
60
61 Ok(())
62 }
63
64 pub fn get_dev_addr_prefixes(&self) -> Vec<lrwn::DevAddrPrefix> {
65 let prefixes: Vec<lrwn::DevAddrPrefix> = (*self.dev_addr_prefixes)

Callers 2

createFunction · 0.45
updateFunction · 0.45

Calls 6

iterMethod · 0.80
is_subset_ofMethod · 0.80
getFunction · 0.70
intoMethod · 0.45
get_dev_addr_prefixesMethod · 0.45
derefMethod · 0.45

Tested by

no test coverage detected