validation.odin 859 B

12345678910111213141516171819202122232425262728293031323334353637
  1. package flags
  2. /*
  3. Check a flag after parsing, during the validation stage.
  4. Inputs:
  5. - model: A raw pointer to the data structure provided to `parse`.
  6. - name: The name of the flag being checked.
  7. - value: An `any` type that contains the value to be checked.
  8. - args_tag: The `args` tag from within the struct.
  9. Returns:
  10. - error: An error message, or an empty string if no error occurred.
  11. */
  12. Custom_Flag_Checker :: #type proc(
  13. model: rawptr,
  14. name: string,
  15. value: any,
  16. args_tag: string,
  17. ) -> (
  18. error: string,
  19. )
  20. @(private)
  21. global_custom_flag_checker: Custom_Flag_Checker
  22. /*
  23. Set the global custom flag checker.
  24. Note that only one can be active at a time.
  25. Inputs:
  26. - checker: The flag checker. Pass `nil` to disable any previously set checker.
  27. */
  28. register_flag_checker :: proc(checker: Custom_Flag_Checker) {
  29. global_custom_flag_checker = checker
  30. }