Files
web/src/validation/channel.ts
2025-03-02 14:46:02 -05:00

52 lines
919 B
TypeScript

import type { Message } from "@bufbuild/protobuf";
import { Protobuf } from "@meshtastic/core";
import {
IsBoolean,
IsEnum,
IsInt,
IsNumber,
IsString,
Length,
} from "class-validator";
export class ChannelValidation
implements Omit<Protobuf.Channel.Channel, keyof Message | "settings"> {
@IsNumber()
index: number;
settings: Channel_SettingsValidation;
@IsEnum(Protobuf.Channel.Channel_Role)
role: Protobuf.Channel.Channel_Role;
}
export class Channel_SettingsValidation
implements Omit<Protobuf.Channel.ChannelSettings, keyof Message | "psk"> {
@IsNumber()
channelNum: number;
@IsString()
psk: string;
@Length(0, 11)
name: string;
@IsInt()
id: number;
@IsBoolean()
uplinkEnabled: boolean;
@IsBoolean()
downlinkEnabled: boolean;
@IsBoolean()
positionEnabled: boolean;
@IsBoolean()
preciseLocation: boolean;
@IsInt()
positionPrecision: number;
}