MCPcopy Create free account
hub / github.com/Dispatcharr/Dispatcharr / getFormValidators

Function getFormValidators

frontend/src/utils/forms/UserUtils.js:128–148  ·  view source on GitHub ↗
(user)

Source from the content-addressed store, hash-verified

126};
127
128export const getFormValidators = (user) => {
129 return (values) => ({
130 username: !values.username
131 ? 'Username is required'
132 : values.user_level == USER_LEVELS.STREAMER &&
133 !values.username.match(/^[a-z0-9]+$/i)
134 ? 'Streamer username must be alphanumeric'
135 : null,
136 password:
137 !user && !values.password && values.user_level != USER_LEVELS.STREAMER
138 ? 'Password is required'
139 : null,
140 xc_password:
141 values.xc_password && !values.xc_password.match(/^[a-z0-9]+$/i)
142 ? 'XC password must be alphanumeric'
143 : null,
144 allowed_ips: (values.allowed_ips || []).some((t) => !isValidNetworkEntry(t))
145 ? 'Invalid IP address or CIDR range'
146 : null,
147 });
148};

Callers 2

UserFunction · 0.90
validateFunction · 0.90

Calls 1

isValidNetworkEntryFunction · 0.85

Tested by 1

validateFunction · 0.72