AshTypescript.NameValidation (ash_typescript v0.18.2)

Copy Markdown View Source

Shared helpers for validating identifiers that need to round-trip through TypeScript codegen. Used by every verifier that flags resource/action/field names producing awkward camelCase output.

A name is invalid if it contains either:

  • an underscore followed by a digit (field_1 → would emit field1, but the underscore is a no-op signal that confuses the formatter), or
  • a trailing ? (Elixir-idiomatic but illegal in JavaScript identifiers).

make_name_better/1 returns the suggestion shown in the error message — drop the spurious underscore, drop the question mark.

Summary

Functions

Returns true when name (atom or string) would produce an awkward TypeScript identifier and should be remapped via field_names / argument_names / metadata_field_names.

Returns the suggested replacement name for use in error messages. Does not apply the configured client formatter — callers should call this only to show the user what to put in their field_names mapping.

Functions

invalid_name?(name)

Returns true when name (atom or string) would produce an awkward TypeScript identifier and should be remapped via field_names / argument_names / metadata_field_names.

make_name_better(name)

Returns the suggested replacement name for use in error messages. Does not apply the configured client formatter — callers should call this only to show the user what to put in their field_names mapping.