code_corps v0.0.1 CodeCorps.Validators.SlugValidator View Source

Used for validating slug fields in a given changeset.

Link to this section Summary

Link to this section Functions

Link to this function validate_slug(changeset, field_name) View Source

Validates a slug.

Matches slugs with:

  • only letters
  • prefixed/suffixed underscores
  • prefixed/suffixed numbers
  • single inside dashes
  • single/multiple inside underscores
  • one character

Prevents slugs with:

  • prefixed symbols
  • prefixed/suffixed dashes
  • multiple consecutive dashes
  • single/multiple/multiple consecutive slashes

Also prevents slugs that conflict with reserved routes for either the API or the web.