guardedstruct
Nested DSLs
- field
- virtual_field
- dynamic_field
- sub_field
- conditional_field
- field
- sub_field
- field
- sub_field
- field
- field
- conditional_field
- conditional_field
- sub_field
- conditional_field
- field
- sub_field
- field
- sub_field
- field
- field
- conditional_field
- conditional_field
- field
- sub_field
- field
- field
- sub_field
Options
| Name | Type | Default | Docs |
|---|---|---|---|
enforce | boolean | false | |
opaque | boolean | false | |
module | any | ||
error | boolean | false | |
authorized_fields | boolean | false | |
main_validator | {atom, atom} | A {Module, :function} called with the attributes once every field has passed its validator; it returns {:ok, attrs} or {:error, errors}. When it is not set, a main_validator/1 defined in the module is called instead. | |
validate_derive | atom | list(atom) | A module, or a list of modules, whose validate/3 serves the validate(...) ops the built-in ones and the derive extensions do not know. They are tried before the :validate_derive application config, which still serves the ops they do not handle. | |
sanitize_derive | atom | list(atom) | A module, or a list of modules, whose sanitize/2 serves the sanitize(...) ops the built-in ones and the derive extensions do not know. They are tried before the :sanitize_derive application config, which still serves the ops they do not handle. | |
json | boolean | false | When true, derives a JSON encoder. Uses Jason.Encoder if :jason is in the user's deps; otherwise falls back to the built-in JSON.Encoder on Elixir 1.18+. No-op if neither is available. |
auto_wire | boolean | false | Only effective inside the GuardedStruct.AshResource extension. When true, injects GuardedStruct.AshResource.Change into the resource's top-level changes section so every :create and :update action automatically runs the GuardedStruct pipeline. Equivalent to writing changes do change GuardedStruct.AshResource.Change end by hand. No-op outside the Ash extension. |
guardedstruct.field
field name, typeArguments
| Name | Type | Default | Docs |
|---|---|---|---|
name | any | ||
type | any |
Options
| Name | Type | Default | Docs |
|---|---|---|---|
enforce | boolean | ||
default | any | ||
derives | String.t | ||
derive | String.t | ||
validator | {atom, atom} | ||
auto | {atom, atom} | {atom, atom, any} | ||
from | String.t | ||
on | String.t | ||
domain | String.t | ||
struct | atom | ||
structs | atom | boolean | ||
hint | String.t | ||
priority | boolean |
guardedstruct.virtual_field
virtual_field name, typeArguments
| Name | Type | Default | Docs |
|---|---|---|---|
name | any | ||
type | any |
Options
| Name | Type | Default | Docs |
|---|---|---|---|
enforce | boolean | ||
default | any | ||
derives | String.t | ||
derive | String.t | ||
validator | {atom, atom} | ||
auto | {atom, atom} | {atom, atom, any} | ||
from | String.t | ||
on | String.t | ||
domain | String.t | ||
hint | String.t |
guardedstruct.dynamic_field
dynamic_field nameArguments
| Name | Type | Default | Docs |
|---|---|---|---|
name | any |
Options
| Name | Type | Default | Docs |
|---|---|---|---|
type | any | {:map, [], []} | |
enforce | boolean | ||
default | any | %{} | |
derives | String.t | "validate(map)" | |
derive | String.t | ||
validator | {atom, atom} | ||
auto | {atom, atom} | {atom, atom, any} | ||
from | String.t | ||
on | String.t | ||
domain | String.t | ||
hint | String.t |
guardedstruct.sub_field
sub_field name, typeNested DSLs
- conditional_field
- field
- sub_field
- field
- sub_field
- field
- field
Arguments
| Name | Type | Default | Docs |
|---|---|---|---|
name | atom | ||
type | any |
Options
| Name | Type | Default | Docs |
|---|---|---|---|
enforce | boolean | ||
default | any | ||
derives | String.t | ||
derive | String.t | ||
validator | {atom, atom} | ||
auto | {atom, atom} | {atom, atom, any} | ||
from | String.t | ||
on | String.t | ||
domain | String.t | ||
struct | atom | ||
structs | atom | boolean | ||
hint | String.t | ||
priority | boolean | ||
error | boolean | ||
authorized_fields | boolean | ||
main_validator | {atom, atom} | A {Module, :function} called with the sub_field's validated attributes, like the section option. A main_validator/1 defined in the parent module does not run for a sub_field. |
guardedstruct.sub_field.conditional_field
conditional_field name, typeNested DSLs
Arguments
| Name | Type | Default | Docs |
|---|---|---|---|
name | atom | ||
type | any |
Options
| Name | Type | Default | Docs |
|---|---|---|---|
enforce | boolean | ||
default | any | ||
derives | String.t | ||
derive | String.t | ||
validator | {atom, atom} | ||
auto | {atom, atom} | {atom, atom, any} | ||
from | String.t | ||
on | String.t | ||
domain | String.t | ||
struct | atom | ||
structs | atom | boolean | ||
hint | String.t | ||
priority | boolean |
guardedstruct.sub_field.conditional_field.field
field name, typeArguments
| Name | Type | Default | Docs |
|---|---|---|---|
name | any | ||
type | any |
Options
| Name | Type | Default | Docs |
|---|---|---|---|
enforce | boolean | ||
default | any | ||
derives | String.t | ||
derive | String.t | ||
validator | {atom, atom} | ||
auto | {atom, atom} | {atom, atom, any} | ||
from | String.t | ||
on | String.t | ||
domain | String.t | ||
struct | atom | ||
structs | atom | boolean | ||
hint | String.t | ||
priority | boolean |
guardedstruct.sub_field.conditional_field.sub_field
sub_field name, typeNested DSLs
Arguments
| Name | Type | Default | Docs |
|---|---|---|---|
name | atom | ||
type | any |
Options
| Name | Type | Default | Docs |
|---|---|---|---|
enforce | boolean | ||
default | any | ||
derives | String.t | ||
derive | String.t | ||
validator | {atom, atom} | ||
auto | {atom, atom} | {atom, atom, any} | ||
from | String.t | ||
on | String.t | ||
domain | String.t | ||
struct | atom | ||
structs | atom | boolean | ||
hint | String.t | ||
priority | boolean | ||
error | boolean | ||
authorized_fields | boolean | ||
main_validator | {atom, atom} | A {Module, :function} called with the sub_field's validated attributes, like the section option. A main_validator/1 defined in the parent module does not run for a sub_field. |
guardedstruct.sub_field.conditional_field.sub_field.field
field name, typeArguments
| Name | Type | Default | Docs |
|---|---|---|---|
name | any | ||
type | any |
Options
| Name | Type | Default | Docs |
|---|---|---|---|
enforce | boolean | ||
default | any | ||
derives | String.t | ||
derive | String.t | ||
validator | {atom, atom} | ||
auto | {atom, atom} | {atom, atom, any} | ||
from | String.t | ||
on | String.t | ||
domain | String.t | ||
struct | atom | ||
structs | atom | boolean | ||
hint | String.t | ||
priority | boolean |
guardedstruct.sub_field.sub_field
sub_field name, typeNested DSLs
Arguments
| Name | Type | Default | Docs |
|---|---|---|---|
name | atom | ||
type | any |
Options
| Name | Type | Default | Docs |
|---|---|---|---|
enforce | boolean | ||
default | any | ||
derives | String.t | ||
derive | String.t | ||
validator | {atom, atom} | ||
auto | {atom, atom} | {atom, atom, any} | ||
from | String.t | ||
on | String.t | ||
domain | String.t | ||
struct | atom | ||
structs | atom | boolean | ||
hint | String.t | ||
priority | boolean | ||
error | boolean | ||
authorized_fields | boolean | ||
main_validator | {atom, atom} | A {Module, :function} called with the sub_field's validated attributes, like the section option. A main_validator/1 defined in the parent module does not run for a sub_field. |
guardedstruct.sub_field.sub_field.field
field name, typeArguments
| Name | Type | Default | Docs |
|---|---|---|---|
name | any | ||
type | any |
Options
| Name | Type | Default | Docs |
|---|---|---|---|
enforce | boolean | ||
default | any | ||
derives | String.t | ||
derive | String.t | ||
validator | {atom, atom} | ||
auto | {atom, atom} | {atom, atom, any} | ||
from | String.t | ||
on | String.t | ||
domain | String.t | ||
struct | atom | ||
structs | atom | boolean | ||
hint | String.t | ||
priority | boolean |
guardedstruct.sub_field.field
field name, typeArguments
| Name | Type | Default | Docs |
|---|---|---|---|
name | any | ||
type | any |
Options
| Name | Type | Default | Docs |
|---|---|---|---|
enforce | boolean | ||
default | any | ||
derives | String.t | ||
derive | String.t | ||
validator | {atom, atom} | ||
auto | {atom, atom} | {atom, atom, any} | ||
from | String.t | ||
on | String.t | ||
domain | String.t | ||
struct | atom | ||
structs | atom | boolean | ||
hint | String.t | ||
priority | boolean |
guardedstruct.conditional_field
conditional_field name, typeNested DSLs
- sub_field
- conditional_field
- field
- sub_field
- field
- sub_field
- field
- field
- conditional_field
- conditional_field
- field
- sub_field
- field
- field
Arguments
| Name | Type | Default | Docs |
|---|---|---|---|
name | atom | ||
type | any |
Options
| Name | Type | Default | Docs |
|---|---|---|---|
enforce | boolean | ||
default | any | ||
derives | String.t | ||
derive | String.t | ||
validator | {atom, atom} | ||
auto | {atom, atom} | {atom, atom, any} | ||
from | String.t | ||
on | String.t | ||
domain | String.t | ||
struct | atom | ||
structs | atom | boolean | ||
hint | String.t | ||
priority | boolean |
guardedstruct.conditional_field.sub_field
sub_field name, typeNested DSLs
- conditional_field
- field
- sub_field
- field
- sub_field
- field
- field
Arguments
| Name | Type | Default | Docs |
|---|---|---|---|
name | atom | ||
type | any |
Options
| Name | Type | Default | Docs |
|---|---|---|---|
enforce | boolean | ||
default | any | ||
derives | String.t | ||
derive | String.t | ||
validator | {atom, atom} | ||
auto | {atom, atom} | {atom, atom, any} | ||
from | String.t | ||
on | String.t | ||
domain | String.t | ||
struct | atom | ||
structs | atom | boolean | ||
hint | String.t | ||
priority | boolean | ||
error | boolean | ||
authorized_fields | boolean | ||
main_validator | {atom, atom} | A {Module, :function} called with the sub_field's validated attributes, like the section option. A main_validator/1 defined in the parent module does not run for a sub_field. |
guardedstruct.conditional_field.sub_field.conditional_field
conditional_field name, typeNested DSLs
Arguments
| Name | Type | Default | Docs |
|---|---|---|---|
name | atom | ||
type | any |
Options
| Name | Type | Default | Docs |
|---|---|---|---|
enforce | boolean | ||
default | any | ||
derives | String.t | ||
derive | String.t | ||
validator | {atom, atom} | ||
auto | {atom, atom} | {atom, atom, any} | ||
from | String.t | ||
on | String.t | ||
domain | String.t | ||
struct | atom | ||
structs | atom | boolean | ||
hint | String.t | ||
priority | boolean |
guardedstruct.conditional_field.sub_field.conditional_field.field
field name, typeArguments
| Name | Type | Default | Docs |
|---|---|---|---|
name | any | ||
type | any |
Options
| Name | Type | Default | Docs |
|---|---|---|---|
enforce | boolean | ||
default | any | ||
derives | String.t | ||
derive | String.t | ||
validator | {atom, atom} | ||
auto | {atom, atom} | {atom, atom, any} | ||
from | String.t | ||
on | String.t | ||
domain | String.t | ||
struct | atom | ||
structs | atom | boolean | ||
hint | String.t | ||
priority | boolean |
guardedstruct.conditional_field.sub_field.conditional_field.sub_field
sub_field name, typeNested DSLs
Arguments
| Name | Type | Default | Docs |
|---|---|---|---|
name | atom | ||
type | any |
Options
| Name | Type | Default | Docs |
|---|---|---|---|
enforce | boolean | ||
default | any | ||
derives | String.t | ||
derive | String.t | ||
validator | {atom, atom} | ||
auto | {atom, atom} | {atom, atom, any} | ||
from | String.t | ||
on | String.t | ||
domain | String.t | ||
struct | atom | ||
structs | atom | boolean | ||
hint | String.t | ||
priority | boolean | ||
error | boolean | ||
authorized_fields | boolean | ||
main_validator | {atom, atom} | A {Module, :function} called with the sub_field's validated attributes, like the section option. A main_validator/1 defined in the parent module does not run for a sub_field. |
guardedstruct.conditional_field.sub_field.conditional_field.sub_field.field
field name, typeArguments
| Name | Type | Default | Docs |
|---|---|---|---|
name | any | ||
type | any |
Options
| Name | Type | Default | Docs |
|---|---|---|---|
enforce | boolean | ||
default | any | ||
derives | String.t | ||
derive | String.t | ||
validator | {atom, atom} | ||
auto | {atom, atom} | {atom, atom, any} | ||
from | String.t | ||
on | String.t | ||
domain | String.t | ||
struct | atom | ||
structs | atom | boolean | ||
hint | String.t | ||
priority | boolean |
guardedstruct.conditional_field.sub_field.sub_field
sub_field name, typeNested DSLs
Arguments
| Name | Type | Default | Docs |
|---|---|---|---|
name | atom | ||
type | any |
Options
| Name | Type | Default | Docs |
|---|---|---|---|
enforce | boolean | ||
default | any | ||
derives | String.t | ||
derive | String.t | ||
validator | {atom, atom} | ||
auto | {atom, atom} | {atom, atom, any} | ||
from | String.t | ||
on | String.t | ||
domain | String.t | ||
struct | atom | ||
structs | atom | boolean | ||
hint | String.t | ||
priority | boolean | ||
error | boolean | ||
authorized_fields | boolean | ||
main_validator | {atom, atom} | A {Module, :function} called with the sub_field's validated attributes, like the section option. A main_validator/1 defined in the parent module does not run for a sub_field. |
guardedstruct.conditional_field.sub_field.sub_field.field
field name, typeArguments
| Name | Type | Default | Docs |
|---|---|---|---|
name | any | ||
type | any |
Options
| Name | Type | Default | Docs |
|---|---|---|---|
enforce | boolean | ||
default | any | ||
derives | String.t | ||
derive | String.t | ||
validator | {atom, atom} | ||
auto | {atom, atom} | {atom, atom, any} | ||
from | String.t | ||
on | String.t | ||
domain | String.t | ||
struct | atom | ||
structs | atom | boolean | ||
hint | String.t | ||
priority | boolean |
guardedstruct.conditional_field.sub_field.field
field name, typeArguments
| Name | Type | Default | Docs |
|---|---|---|---|
name | any | ||
type | any |
Options
| Name | Type | Default | Docs |
|---|---|---|---|
enforce | boolean | ||
default | any | ||
derives | String.t | ||
derive | String.t | ||
validator | {atom, atom} | ||
auto | {atom, atom} | {atom, atom, any} | ||
from | String.t | ||
on | String.t | ||
domain | String.t | ||
struct | atom | ||
structs | atom | boolean | ||
hint | String.t | ||
priority | boolean |
guardedstruct.conditional_field.conditional_field
conditional_field name, typeNested DSLs
Arguments
| Name | Type | Default | Docs |
|---|---|---|---|
name | atom | ||
type | any |
Options
| Name | Type | Default | Docs |
|---|---|---|---|
enforce | boolean | ||
default | any | ||
derives | String.t | ||
derive | String.t | ||
validator | {atom, atom} | ||
auto | {atom, atom} | {atom, atom, any} | ||
from | String.t | ||
on | String.t | ||
domain | String.t | ||
struct | atom | ||
structs | atom | boolean | ||
hint | String.t | ||
priority | boolean |
guardedstruct.conditional_field.conditional_field.field
field name, typeArguments
| Name | Type | Default | Docs |
|---|---|---|---|
name | any | ||
type | any |
Options
| Name | Type | Default | Docs |
|---|---|---|---|
enforce | boolean | ||
default | any | ||
derives | String.t | ||
derive | String.t | ||
validator | {atom, atom} | ||
auto | {atom, atom} | {atom, atom, any} | ||
from | String.t | ||
on | String.t | ||
domain | String.t | ||
struct | atom | ||
structs | atom | boolean | ||
hint | String.t | ||
priority | boolean |
guardedstruct.conditional_field.conditional_field.sub_field
sub_field name, typeNested DSLs
Arguments
| Name | Type | Default | Docs |
|---|---|---|---|
name | atom | ||
type | any |
Options
| Name | Type | Default | Docs |
|---|---|---|---|
enforce | boolean | ||
default | any | ||
derives | String.t | ||
derive | String.t | ||
validator | {atom, atom} | ||
auto | {atom, atom} | {atom, atom, any} | ||
from | String.t | ||
on | String.t | ||
domain | String.t | ||
struct | atom | ||
structs | atom | boolean | ||
hint | String.t | ||
priority | boolean | ||
error | boolean | ||
authorized_fields | boolean | ||
main_validator | {atom, atom} | A {Module, :function} called with the sub_field's validated attributes, like the section option. A main_validator/1 defined in the parent module does not run for a sub_field. |
guardedstruct.conditional_field.conditional_field.sub_field.field
field name, typeArguments
| Name | Type | Default | Docs |
|---|---|---|---|
name | any | ||
type | any |
Options
| Name | Type | Default | Docs |
|---|---|---|---|
enforce | boolean | ||
default | any | ||
derives | String.t | ||
derive | String.t | ||
validator | {atom, atom} | ||
auto | {atom, atom} | {atom, atom, any} | ||
from | String.t | ||
on | String.t | ||
domain | String.t | ||
struct | atom | ||
structs | atom | boolean | ||
hint | String.t | ||
priority | boolean |
guardedstruct.conditional_field.field
field name, typeArguments
| Name | Type | Default | Docs |
|---|---|---|---|
name | any | ||
type | any |
Options
| Name | Type | Default | Docs |
|---|---|---|---|
enforce | boolean | ||
default | any | ||
derives | String.t | ||
derive | String.t | ||
validator | {atom, atom} | ||
auto | {atom, atom} | {atom, atom, any} | ||
from | String.t | ||
on | String.t | ||
domain | String.t | ||
struct | atom | ||
structs | atom | boolean | ||
hint | String.t | ||
priority | boolean |