MCPcopy
hub / github.com/NginxProxyManager/nginx-proxy-manager / validate

Function validate

frontend/src/modals/AccessListModal.tsx:27–41  ·  view source on GitHub ↗
(values: any)

Source from the content-addressed store, hash-verified

25 const [isSubmitting, setIsSubmitting] = useState(false);
26
27 const validate = (values: any): string | null => {
28 // either Auths or Clients must be defined
29 if (values.items?.length === 0 && values.clients?.length === 0) {
30 return intl.formatMessage({ id: "error.access.at-least-one" });
31 }
32
33 // ensure the items don't contain the same username twice
34 const usernames = values.items.map((i: any) => i.username);
35 const uniqueUsernames = Array.from(new Set(usernames));
36 if (usernames.length !== uniqueUsernames.length) {
37 return intl.formatMessage({ id: "error.access.duplicate-usernames" });
38 }
39
40 return null;
41 };
42
43 const onSubmit = async (values: any, { setSubmitting }: any) => {
44 if (isSubmitting) return;

Callers 3

onSubmitFunction · 0.85
validatorFunction · 0.85
apiValidatorFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected