View Source Dropkick.Changeset (dropkick v0.0.1)

Link to this section Summary

Functions

Validates that the given field of type Dropkick.File has the allowed extensions. This function should be considered unsafe unless you define your file fields with infer: true.

Validates that the given field of type Dropkick.File has the allowed size in bytes.

Validates that the given field of type Dropkick.File has the allowed content types. This function should be considered unsafe unless you define your file fields with infer: true.

Link to this section Functions

Link to this function

validate_file_extension(changeset, field, extensions)

View Source

Validates that the given field of type Dropkick.File has the allowed extensions. This function should be considered unsafe unless you define your file fields with infer: true.

example

Example

validate_file_extension(changeset, :avatar, ~w(png jpg))
Link to this function

validate_file_size(changeset, field, opts)

View Source

Validates that the given field of type Dropkick.File has the allowed size in bytes.

options

Options

  • :is: The file size must be exactly this value.
  • :max: The file size must be less than this value.
  • :min: The file size must be greater than this value.

example

Example

validate_file_size(changeset, :avatar, max: 10 * 1024 * 1024)
Link to this function

validate_file_type(changeset, field, content_types)

View Source

Validates that the given field of type Dropkick.File has the allowed content types. This function should be considered unsafe unless you define your file fields with infer: true.

example

Example

validate_file_type(changeset, :avatar, ~w(image/jpeg image/jpeg))