Scala Library for Naming Convention Transitions (camelCase, PascalCase, snake_case, kebab-case, etc.)
✂️ Split words in any kind of Naming Convention
🪶 Dependency free
🧪 Fully tested
To include Casing in your Scala project, add the following dependency:
libraryDependencies += "io.github.ranyitz" %% "casing" % "0.2.0"
import casing._
camelCase("foo_bar") // fooBar
pascalCase("foo bar") // FooBar
snakeCase("fooBar") // foo_bar
kebabCase("foo-bar") // foo-bar
constantCase("foo.bar") // FOO_BAR
caseSplit("fooBarBaz") // foo.bar.baz
.map(_.toLowerCase())
.mkString(".")
splits a string into words based on the casing pattern
can be used to create any custom naming pattern
caseSplit("fooBarBaz") // Seq(foo, Bar, Baz)
caseSplit("foo_bar_baz") // Seq(foo, bar, baz)
caseSplit("foo-bar-baz") // Seq(foo, bar, baz)
caseSplit("FOO_BAR_BAZ") // List(FOO, BAR, BAZ)
converts a string to camelCase
camelCase("foo_bar") // fooBar
converts a string to PascalCase
pascalCase("foo_bar") // FooBar
converts a string to snake_case
snakeCase("fooBar") // foo_bar
converts a string to kebab-case
kebabCase("fooBar") // foo-bar
converts a string to CONSTANT_CASE or SCREAMING_SNAKE_CASE
constantCase("fooBar") // FOO_BAR
validates a string against a specific naming convention
isCamelCase("fooBar") // true
isPascalCase("FooBar") // true
isSnakeCase("foo_bar") // true
isKebabCase("foo-bar") // true
isConstantCase("FOO_BAR") // true