Params

screenshot of Params

Easy parameters validation/casting with Ecto.Schema, akin to Rails' strong parameters.

Overview

Params is a powerful tool for anyone working with Ecto in Elixir applications, simplifying the process of defining parameter structures and validating data inputs. Built on the foundation of Ecto.Schema and Ecto.Changeset, it allows you to handle request parameters seamlessly, reducing boilerplate code while maintaining flexibility. This feature is especially beneficial for developers creating REST APIs, ensuring that incoming data conforms to specified formats without needing extensive manual checks.

The ease of use offered by Params makes it an essential addition to any Ecto-based project. With its ability to create customizable changesets and validate various parameters, you can streamline your application's data handling process, making it both efficient and reliable.

Features

  • Efficient Parameter Management: Easily define and manage parameter structures for your Ecto-based application, enhancing clarity and control over incoming data.

  • Customizable Changesets: Create custom changesets tailored to your application's needs, allowing for robust validation and type casting of inputs.

  • Flexible Fields: With the ability to specify optional and required fields using simple syntax, you can quickly enforce rules without extensive configuration.

  • Simplified Boilerplate Code: Reduce repetitive code by leveraging the defparams macro, which automatically generates modules for processing parameter schemas.

  • Data Handling Methods: Utilize Params.data to retrieve a struct containing all valid parameters, or use Params.to_map to get a map of only the submitted keys for better control over your data structure.

  • Seamless Integration: Designed to work harmoniously with existing Ecto structures, making transitions simple without needing to overhaul your current codebase.

  • Enhanced API Development: Ideal for creating RESTful APIs, ensuring that data validation and parameter structure enforcement are both streamlined and effective.