MCPcopy Create free account
hub / github.com/aeroxy/chrome-devtools-cli / validate

Method validate

src/commands/emulation.rs:27–48  ·  view source on GitHub ↗

Validate cross-field constraints before applying emulation.

(&self)

Source from the content-addressed store, hash-verified

25impl EmulateParams {
26 /// Validate cross-field constraints before applying emulation.
27 pub fn validate(&self) -> Result<()> {
28 if let Some(dsf) = self.device_scale_factor {
29 if !dsf.is_finite() || dsf <= 0.0 {
30 anyhow::bail!("device-scale-factor must be a positive finite value");
31 }
32 }
33 if let Some(acc) = self.accuracy {
34 if acc.is_sign_negative() || !acc.is_finite() {
35 anyhow::bail!("accuracy must be a non-negative finite value");
36 }
37 }
38 if self.accuracy.is_some() && self.geolocation.is_none() {
39 anyhow::bail!("--accuracy requires --geolocation");
40 }
41 if self.mobile && self.viewport.is_none() {
42 anyhow::bail!("--mobile requires --viewport");
43 }
44 if self.device_scale_factor.is_some() && self.viewport.is_none() {
45 anyhow::bail!("--device-scale-factor requires --viewport");
46 }
47 Ok(())
48 }
49
50 /// Returns true if any flag that triggers emulation is set.
51 pub fn has_emulation(&self) -> bool {

Callers 3

run_directFunction · 0.80
execute_commandFunction · 0.80
inner_executeFunction · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected