-
Notifications
You must be signed in to change notification settings - Fork 144
/
ap.ts
40 lines (37 loc) · 1.42 KB
/
ap.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import Schema from 'async-validator';
import { APSettings } from '../types';
import { isAPEnabled } from '../framework/ap/APSettingsForm';
import { IP_ADDRESS_VALIDATOR } from './shared';
export const createAPSettingsValidator = (apSettings: APSettings) => new Schema({
provision_mode: { required: true, message: "Please provide a provision mode" },
...(isAPEnabled(apSettings) && {
ssid: [
{ required: true, message: "Please provide an SSID" },
{ type: "string", max: 32, message: "SSID must be 32 characters or less" }
],
password: [
{ required: true, message: "Please provide an access point password" },
{ type: "string", min: 8, max: 64, message: "Password must be 8-64 characters" }
],
channel: [
{ required: true, message: "Please provide a network channel" },
{ type: "number", message: "Channel must be between 1 and 14" }
],
max_clients: [
{ required: true, message: "Please specify a value for max clients" },
{ type: "number", min: 1, max: 9, message: "Max clients must be between 1 and 9" }
],
local_ip: [
{ required: true, message: "Local IP address is required" },
IP_ADDRESS_VALIDATOR
],
gateway_ip: [
{ required: true, message: "Gateway IP address is required" },
IP_ADDRESS_VALIDATOR
],
subnet_mask: [
{ required: true, message: "Subnet mask is required" },
IP_ADDRESS_VALIDATOR
]
})
});