Twm.Validators (Twm v0.1.0)

View Source

Provides functions for validating Tailwind CSS class values.

Port of the TypeScript validators in tailwind-merge.

Summary

Functions

Always returns true. Used for validators that accept any value.

Returns true if the value is not an arbitrary value or variable.

Returns true if the value is an arbitrary image (e.g., "[url:var(--my-url)]").

Returns true if the value is an arbitrary length (e.g., "[10px]").

Returns true if the value is an arbitrary number (e.g., "[10]").

Returns true if the value is an arbitrary position (e.g., "[position:center]").

Returns true if the value is an arbitrary shadow (e.g., "[035px_60px-15px_rgba(0,0,0,0.3)]").

Returns true if the value is an arbitrary size (e.g., "[size:10px]").

Returns true if the value is an arbitrary value (e.g., "[value]").

Returns true if the value is an arbitrary variable (e.g., "(variable)").

Returns true if the value is an arbitrary variable family name (e.g., "(family-name:var(--font))").

Returns true if the value is an arbitrary variable image (e.g., "(image:var(--img))").

Returns true if the value is an arbitrary variable length (e.g., "(length:var(--size))").

Returns true if the value is an arbitrary variable position (e.g., "(position:var(--pos))").

Returns true if the value is an arbitrary variable shadow (e.g., "(shadow:var(--shadow))").

Returns true if the value is an arbitrary variable size (e.g., "(size:var(--size))").

Returns true if the value is a fraction (e.g., "1/2").

Returns true if the value is an integer.

Returns true if the value is a number.

Returns true if the value is a t-shirt size (e.g., "xs", "sm", "md", "lg", "xl", "2xl").

Returns true if the value is a percentage.

Functions

any?()

@spec any?() :: boolean()

Always returns true. Used for validators that accept any value.

any?(_)

is_any_non_arbitrary(value)

@spec is_any_non_arbitrary(String.t()) :: boolean()

Returns true if the value is not an arbitrary value or variable.

is_arbitrary_image(value)

@spec is_arbitrary_image(String.t()) :: boolean()

Returns true if the value is an arbitrary image (e.g., "[url:var(--my-url)]").

is_arbitrary_length(value)

@spec is_arbitrary_length(String.t()) :: boolean()

Returns true if the value is an arbitrary length (e.g., "[10px]").

is_arbitrary_number(value)

@spec is_arbitrary_number(String.t()) :: boolean()

Returns true if the value is an arbitrary number (e.g., "[10]").

is_arbitrary_position(value)

@spec is_arbitrary_position(String.t()) :: boolean()

Returns true if the value is an arbitrary position (e.g., "[position:center]").

is_arbitrary_shadow(value)

@spec is_arbitrary_shadow(String.t()) :: boolean()

Returns true if the value is an arbitrary shadow (e.g., "[035px_60px-15px_rgba(0,0,0,0.3)]").

is_arbitrary_size(value)

@spec is_arbitrary_size(String.t()) :: boolean()

Returns true if the value is an arbitrary size (e.g., "[size:10px]").

is_arbitrary_value(value)

@spec is_arbitrary_value(String.t()) :: boolean()

Returns true if the value is an arbitrary value (e.g., "[value]").

is_arbitrary_variable(value)

@spec is_arbitrary_variable(String.t()) :: boolean()

Returns true if the value is an arbitrary variable (e.g., "(variable)").

is_arbitrary_variable_family_name(value)

@spec is_arbitrary_variable_family_name(String.t()) :: boolean()

Returns true if the value is an arbitrary variable family name (e.g., "(family-name:var(--font))").

is_arbitrary_variable_image(value)

@spec is_arbitrary_variable_image(String.t()) :: boolean()

Returns true if the value is an arbitrary variable image (e.g., "(image:var(--img))").

is_arbitrary_variable_length(value)

@spec is_arbitrary_variable_length(String.t()) :: boolean()

Returns true if the value is an arbitrary variable length (e.g., "(length:var(--size))").

is_arbitrary_variable_position(value)

@spec is_arbitrary_variable_position(String.t()) :: boolean()

Returns true if the value is an arbitrary variable position (e.g., "(position:var(--pos))").

is_arbitrary_variable_shadow(value)

@spec is_arbitrary_variable_shadow(String.t()) :: boolean()

Returns true if the value is an arbitrary variable shadow (e.g., "(shadow:var(--shadow))").

is_arbitrary_variable_size(value)

@spec is_arbitrary_variable_size(String.t()) :: boolean()

Returns true if the value is an arbitrary variable size (e.g., "(size:var(--size))").

is_fraction(value)

@spec is_fraction(String.t()) :: boolean()

Returns true if the value is a fraction (e.g., "1/2").

is_integer_value(value)

@spec is_integer_value(String.t()) :: boolean()

Returns true if the value is an integer.

is_number_value(value)

@spec is_number_value(String.t()) :: boolean()

Returns true if the value is a number.

is_tshirt_size(value)

@spec is_tshirt_size(String.t()) :: boolean()

Returns true if the value is a t-shirt size (e.g., "xs", "sm", "md", "lg", "xl", "2xl").

percent?(value)

@spec percent?(String.t()) :: boolean()

Returns true if the value is a percentage.