main/
main.rs

1use ph_mobile_network::mobile_network::MobileNetwork;
2use ph_mobile_network::mutate::{append_dito_prefixes, append_globe_prefixes, append_smart_prefixes, append_sun_prefixes, append_tnt_prefixes, reset_dito_prefixes, reset_globe_prefixes, reset_smart_prefixes, reset_sun_prefixes, reset_tnt_prefixes};
3use ph_mobile_network::validate::Validate;
4
5
6fn main() {
7    // if for some reason the default library prefixes has invalid values you can always reset it
8    reset_dito_prefixes();
9    reset_globe_prefixes();
10    reset_smart_prefixes();
11    reset_sun_prefixes();
12    reset_tnt_prefixes();
13    // if the current prefix isnt supported yet by the library you can always append it on compile time
14    // append new prefixes on different networks
15    append_dito_prefixes(&["0911", "0912"]); // Adding new TNT prefixes
16    append_globe_prefixes(&["0917", "0996"]); // Adding new Globe prefixes
17    append_smart_prefixes(&["0918", "0919"]); // Adding new Smart prefixes
18    append_sun_prefixes(&["0933", "0934"]); // Adding new Sun prefixes
19    append_tnt_prefixes(&["0899", "0900"]); // Adding new Dito prefixes
20
21    // Example phone number to validate
22    let number = "09171234567";
23
24    // Get the network based on the phone number and validate the number
25    match MobileNetwork::get(number) {
26        Ok(network) => {
27            println!("Network identified: {}", network.to_string());
28            match network.validate(number) {
29                Ok(valid) => println!("Validation result: {}", valid),
30                Err(e) => println!("Validation error: {:?}", e),
31            }
32        },
33        Err(e) => println!("Error retrieving network: {:?}", e),
34    }
35}
36