mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-07 08:19:52 +03:00
added status and renamed components
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
import Schema from 'async-validator';
|
||||
import { IP_ADDRESS_VALIDATOR } from './shared';
|
||||
import type { APSettings } from 'types';
|
||||
import { isAPEnabled } from 'framework/ap/APSettingsForm';
|
||||
import type { APSettingsType } from 'types';
|
||||
import { isAPEnabled } from 'framework/ap/APSettings';
|
||||
|
||||
export const createAPSettingsValidator = (apSettings: APSettings) =>
|
||||
export const createAPSettingsValidator = (apSettings: APSettingsType) =>
|
||||
new Schema({
|
||||
provision_mode: { required: true, message: 'Please provide a provision mode' },
|
||||
...(isAPEnabled(apSettings) && {
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import Schema from 'async-validator';
|
||||
import { IP_OR_HOSTNAME_VALIDATOR } from './shared';
|
||||
import type { MqttSettings } from 'types';
|
||||
import type { MqttSettingsType } from 'types';
|
||||
|
||||
export const createMqttSettingsValidator = (mqttSettings: MqttSettings) =>
|
||||
export const createMqttSettingsValidator = (mqttSettings: MqttSettingsType) =>
|
||||
new Schema({
|
||||
...(mqttSettings.enabled && {
|
||||
host: [{ required: true, message: 'Host is required' }, IP_OR_HOSTNAME_VALIDATOR],
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import Schema from 'async-validator';
|
||||
import { HOSTNAME_VALIDATOR, IP_ADDRESS_VALIDATOR } from './shared';
|
||||
import type { NetworkSettings } from 'types';
|
||||
import type { NetworkSettingsType } from 'types';
|
||||
|
||||
export const createNetworkSettingsValidator = (networkSettings: NetworkSettings) =>
|
||||
export const createNetworkSettingsValidator = (networkSettings: NetworkSettingsType) =>
|
||||
new Schema({
|
||||
ssid: [{ type: 'string', max: 32, message: 'SSID must be 32 characters or less' }],
|
||||
bssid: [{ type: 'string', max: 17, message: 'BSSID must be 17 characters or empty' }],
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import Schema from 'async-validator';
|
||||
import type { InternalRuleItem } from 'async-validator';
|
||||
import type { User } from 'types';
|
||||
import type { UserType } from 'types';
|
||||
|
||||
export const SECURITY_SETTINGS_VALIDATOR = new Schema({
|
||||
jwt_secret: [
|
||||
@@ -9,7 +9,7 @@ export const SECURITY_SETTINGS_VALIDATOR = new Schema({
|
||||
]
|
||||
});
|
||||
|
||||
export const createUniqueUsernameValidator = (users: User[]) => ({
|
||||
export const createUniqueUsernameValidator = (users: UserType[]) => ({
|
||||
validator(rule: InternalRuleItem, username: string, callback: (error?: string) => void) {
|
||||
if (username && users.find((u) => u.username === username)) {
|
||||
callback('Username already in use');
|
||||
@@ -19,7 +19,7 @@ export const createUniqueUsernameValidator = (users: User[]) => ({
|
||||
}
|
||||
});
|
||||
|
||||
export const createUserValidator = (users: User[], creating: boolean) =>
|
||||
export const createUserValidator = (users: UserType[], creating: boolean) =>
|
||||
new Schema({
|
||||
username: [
|
||||
{ required: true, message: 'Username is required' },
|
||||
|
||||
Reference in New Issue
Block a user