MCPcopy Create free account
hub / github.com/danielmiessler/Fabric / validate_pattern

Function validate_pattern

scripts/python_ui/streamlit.py:916–940  ·  view source on GitHub ↗

Validate a pattern's structure and content.

(pattern_name)

Source from the content-addressed store, hash-verified

914
915
916def validate_pattern(pattern_name):
917 """Validate a pattern's structure and content."""
918 try:
919 pattern_path = os.path.join(pattern_dir, pattern_name)
920
921 if not os.path.exists(os.path.join(pattern_path, "system.md")):
922 return False, f"Missing required file: system.md."
923
924 with open(os.path.join(pattern_path, "system.md")) as f:
925 content = f.read()
926 required_sections = ["# IDENTITY", "# STEPS", "# OUTPUT"]
927 missing_sections = []
928 for section in required_sections:
929 if section.lower() not in content.lower():
930 missing_sections.append(section)
931
932 if missing_sections:
933 return (
934 True,
935 f"Warning: Missing sections in system.md: {', '.join(missing_sections)}",
936 )
937
938 return True, "Pattern is valid."
939 except Exception as e:
940 return False, f"Error validating pattern: {str(e)}"
941
942
943def pattern_editor(pattern_name):

Callers 2

create_patternFunction · 0.85
pattern_editorFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected