Fix network validation
This commit is contained in:
@@ -132,32 +132,32 @@ export const Network = (): JSX.Element => {
|
|||||||
disabled={!ethEnabled}
|
disabled={!ethEnabled}
|
||||||
{...register("ethMode", { valueAsNumber: true })}
|
{...register("ethMode", { valueAsNumber: true })}
|
||||||
>
|
>
|
||||||
{renderOptions(Protobuf.Config_NetworkConfig_WiFiMode)}
|
{renderOptions(Protobuf.Config_NetworkConfig_EthMode)}
|
||||||
</Select>
|
</Select>
|
||||||
</FormSection>
|
</FormSection>
|
||||||
<FormSection title="IP Config">
|
<FormSection title="IP Config">
|
||||||
<Input
|
<Input
|
||||||
label="IP"
|
label="IP"
|
||||||
description="IP Address"
|
description="IP Address"
|
||||||
error={errors.wifiSsid?.message}
|
error={errors.ethConfig?.ip?.message}
|
||||||
{...register("ethConfig.ip")}
|
{...register("ethConfig.ip")}
|
||||||
/>
|
/>
|
||||||
<Input
|
<Input
|
||||||
label="Gateway"
|
label="Gateway"
|
||||||
description="Default Gateway"
|
description="Default Gateway"
|
||||||
error={errors.wifiSsid?.message}
|
error={errors.ethConfig?.gateway?.message}
|
||||||
{...register("ethConfig.gateway")}
|
{...register("ethConfig.gateway")}
|
||||||
/>
|
/>
|
||||||
<Input
|
<Input
|
||||||
label="Subnet"
|
label="Subnet"
|
||||||
description="Subnet Mask"
|
description="Subnet Mask"
|
||||||
error={errors.wifiSsid?.message}
|
error={errors.ethConfig?.subnet?.message}
|
||||||
{...register("ethConfig.subnet")}
|
{...register("ethConfig.subnet")}
|
||||||
/>
|
/>
|
||||||
<Input
|
<Input
|
||||||
label="DNS"
|
label="DNS"
|
||||||
description="DNS Server"
|
description="DNS Server"
|
||||||
error={errors.wifiSsid?.message}
|
error={errors.ethConfig?.dns?.message}
|
||||||
{...register("ethConfig.dns")}
|
{...register("ethConfig.dns")}
|
||||||
/>
|
/>
|
||||||
</FormSection>
|
</FormSection>
|
||||||
@@ -165,7 +165,6 @@ export const Network = (): JSX.Element => {
|
|||||||
label="NTP Server"
|
label="NTP Server"
|
||||||
description="NTP server for time synchronization"
|
description="NTP server for time synchronization"
|
||||||
error={errors.ntpServer?.message}
|
error={errors.ntpServer?.message}
|
||||||
disabled={!wifiEnabled && !ethEnabled}
|
|
||||||
{...register("ntpServer")}
|
{...register("ntpServer")}
|
||||||
/>
|
/>
|
||||||
</Form>
|
</Form>
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { IsBoolean, IsEnum, IsIP, Length } from "class-validator";
|
import { IsBoolean, IsEnum, IsIP, IsOptional, Length } from "class-validator";
|
||||||
|
|
||||||
import { Protobuf } from "@meshtastic/meshtasticjs";
|
import { Protobuf } from "@meshtastic/meshtasticjs";
|
||||||
|
|
||||||
@@ -9,10 +9,12 @@ export class NetworkValidation implements Protobuf.Config_NetworkConfig {
|
|||||||
@IsEnum(Protobuf.Config_NetworkConfig_WiFiMode)
|
@IsEnum(Protobuf.Config_NetworkConfig_WiFiMode)
|
||||||
wifiMode: Protobuf.Config_NetworkConfig_WiFiMode;
|
wifiMode: Protobuf.Config_NetworkConfig_WiFiMode;
|
||||||
|
|
||||||
@Length(1, 33)
|
@Length(0, 33) //min 1
|
||||||
|
@IsOptional({})
|
||||||
wifiSsid: string;
|
wifiSsid: string;
|
||||||
|
|
||||||
@Length(8, 64)
|
@Length(0, 64) //min 8
|
||||||
|
@IsOptional()
|
||||||
wifiPsk: string;
|
wifiPsk: string;
|
||||||
|
|
||||||
@Length(2, 30)
|
@Length(2, 30)
|
||||||
@@ -31,14 +33,18 @@ export class NetworkValidation_IpV4Config
|
|||||||
implements Protobuf.Config_NetworkConfig_IpV4Config
|
implements Protobuf.Config_NetworkConfig_IpV4Config
|
||||||
{
|
{
|
||||||
@IsIP()
|
@IsIP()
|
||||||
|
@IsOptional()
|
||||||
ip: number;
|
ip: number;
|
||||||
|
|
||||||
@IsIP()
|
@IsIP()
|
||||||
|
@IsOptional()
|
||||||
gateway: number;
|
gateway: number;
|
||||||
|
|
||||||
@IsIP()
|
@IsIP()
|
||||||
|
@IsOptional()
|
||||||
subnet: number;
|
subnet: number;
|
||||||
|
|
||||||
@IsIP()
|
@IsIP()
|
||||||
|
@IsOptional()
|
||||||
dns: number;
|
dns: number;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user