MCPcopy Create free account
hub / github.com/Openpanel-dev/openpanel / validateContent

Function validateContent

apps/start/src/components/json-editor.tsx:44–71  ·  view source on GitHub ↗
(content: string)

Source from the content-addressed store, hash-verified

42 const isUpdatingRef = useRef(false);
43
44 const validateContent = (content: string) => {
45 if (!content.trim()) {
46 setIsValid(true);
47 setError(undefined);
48 onValidate?.(true);
49 return;
50 }
51
52 if (language === 'json') {
53 try {
54 JSON.parse(content);
55 setIsValid(true);
56 setError(undefined);
57 onValidate?.(true);
58 } catch (e) {
59 setIsValid(false);
60 const errorMsg =
61 e instanceof Error ? e.message : 'Invalid JSON syntax';
62 setError(errorMsg);
63 onValidate?.(false, errorMsg);
64 }
65 } else if (language === 'javascript') {
66 // No frontend validation for JavaScript - validation happens in tRPC
67 setIsValid(true);
68 setError(undefined);
69 onValidate?.(true);
70 }
71 };
72
73 // Create editor once on mount
74 useEffect(() => {

Callers 1

JsonEditorFunction · 0.85

Calls 1

parseMethod · 0.80

Tested by

no test coverage detected