Ash.Type.CompositeTypeHelpers (ash v3.9.0)
View SourceShared utilities for composite type validation and error handling.
This module provides common functions used by composite types like TypedStruct, Map, Keyword, and Struct for handling validation errors and converting them to consistent formats.
Summary
Functions
Converts constraint errors to keyword list format, ensuring each error has a :field key set to the specified field name.
Converts validation errors from composite types to InvalidAttribute exceptions.
Filters out non-informative constraint errors.
Formats a single constraint error as a comprehensive keyword list.
Functions
Converts constraint errors to keyword list format, ensuring each error has a :field key set to the specified field name.
This is used by Map, Keyword, and Struct types to normalize error formats from nested type validations.
Converts validation errors from composite types to InvalidAttribute exceptions.
Handles multiple error formats:
- Single keyword list errors
- Lists of keyword list errors
- Other error formats (passed through to Ash.Error.to_ash_error)
For backward compatibility with typed_struct.ex, returns a single error for single error lists, and multiple errors for multiple error lists.
Filters out non-informative constraint errors.
Removes constraint key-value pairs that don't provide meaningful error messages to users.
Formats a single constraint error as a comprehensive keyword list.
This handles the complex error formatting logic from struct.ex, including filtering out non-informative constraint key-value pairs and ensuring proper field assignment.