An ATProto Lexicon validator for Gleam.

format

Changed files
+15 -6
src
honk
validation
+13 -5
src/honk.gleam
··· 77 77 let message = case e { 78 78 errors.InvalidSchema(msg) -> msg 79 79 errors.DataValidation(msg) -> msg 80 - errors.LexiconNotFound(msg) -> "Lexicon not found: " <> msg 80 + errors.LexiconNotFound(msg) -> 81 + "Lexicon not found: " <> msg 81 82 } 82 83 // Clean up leading ": " if present 83 - let clean_message = case string.starts_with(message, ": ") { 84 + let clean_message = case 85 + string.starts_with(message, ": ") 86 + { 84 87 True -> string.drop_start(message, 2) 85 88 False -> message 86 89 } 87 - let error_msg = lex_id <> "#" <> def_name <> ": " <> clean_message 90 + let error_msg = 91 + lex_id <> "#" <> def_name <> ": " <> clean_message 88 92 case dict.get(errors_acc, lex_id) { 89 93 Ok(existing_errors) -> 90 94 dict.insert(errors_acc, lex_id, [ ··· 221 225 case simplifile.is_directory(path) { 222 226 Ok(True) -> validate_directory(path) 223 227 Ok(False) -> { 224 - io.println_error("Error: Path is neither a file nor a directory: " <> path) 228 + io.println_error( 229 + "Error: Path is neither a file nor a directory: " <> path, 230 + ) 225 231 Nil 226 232 } 227 233 Error(_) -> { ··· 367 373 case total_errors { 368 374 0 -> 369 375 io.println( 370 - "\nAll " <> int.to_string(total) <> " schemas validated successfully.", 376 + "\nAll " 377 + <> int.to_string(total) 378 + <> " schemas validated successfully.", 371 379 ) 372 380 _ -> 373 381 io.println_error(
+2 -1
src/honk/validation/field/reference.gleam
··· 44 44 45 45 // Validate that the reference can be resolved (only for global refs with full context) 46 46 case string.starts_with(ref_str, "#") { 47 - True -> Ok(Nil) // Local ref - will be validated in same lexicon 47 + True -> Ok(Nil) 48 + // Local ref - will be validated in same lexicon 48 49 False -> { 49 50 // Global ref - check it exists in catalog if we have a current lexicon 50 51 case context.current_lexicon_id(ctx) {