shahryarjb

shahryarjb

Mishka developer tools - macros and modules to make creating your elixir application

I tried to deliver a series of our client’s CMS built on Elixir at the start of the my small group project, but we recently archived this open-source project and have yet to make plans to rework and expand it. After a long period, a series of macros and functional modules emerged from this project and our other projects, which we are gradually publishing in this library.

The creation of this macro will allow you to build normal/nested Structs that provide you with a number of important options, including the following:

  1. Validation
  2. Sanitizing
  3. Constructor
  4. It provides the capacity to operate in a nested style simultaneously.

This is the latest macro that I put in this library and it makes good features for you with the help of struct. Please click on the name of this macro to see different examples of it.


Creating basic CRUD; This macro needs to be rewritten and it is a simple macro that can be very useful to save your time.

I will gradually add some other modules and macros that may be useful to this post, please do not hesitate to give me your comments and suggestions.


Links

Hex: mishka_developer_tools | Hex
Documents: MishkaDeveloperTools — Mishka developer tools v0.1.10
Github: GitHub - mishka-group/mishka_developer_tools: Mishka developer tools provides some macros and modules to make creating your elixir application as easy as possible · GitHub

Most Liked

shahryarjb

shahryarjb

We are delighted to introduce our new version (0.1.3) of Mishka developer tools library.

For more info click on GuardedStruct.


RoadMap 0.1.4: Predefined validations and sanitizers version 0.1.4 · Issue #8 · mishka-group/guarded_struct · GitHub


Changelog for MishkaDeveloperTools 0.1.3

Features:

  • Support List conditional_field
"actor": [
  "http://joe.example.org",
  {
    "type": "Person",
    "id": "http://sally.example.org",
    "name": "Sally"
  },
  :test
]
  • Covering hint inside derive conditional_field and normal derive
  • Support domain key inside children fields
  • Support new derives: not_flatten_empty, not_flatten_empty_item as validation
  • Support not_empty and max_len, min_len for list in validation derive.

Fixed bugs:

  • Fix and Remove downcase bug in strip_tags
  • Fix and Remove preventer of calling a struct inside itself
  • Fix domain core key to prevent it not to check domain when the key is nil

Improvements:

  • Changing the structure of on core key based on the value of the caller
  • Support calling struct inside itself
  • Separate all test of GuardedStruct macro in different files
  • Add dialyzer for GuardedStruct macro

Github: Release 0.1.3 · mishka-group/mishka_developer_tools · GitHub
Hex: mishka_developer_tools | Hex

If you can contribute with me in this way, please contact me

shahryarjb

shahryarjb

We are delighted to introduce our new version (0.1.4) of Mishka developer tools library. For more info click on GuardedStruct.

Run in Livebook


RoadMap 0.1.5: Predefined validations and sanitizers version 0.1.5 · Issue #27 · mishka-group/mishka_developer_tools · GitHub


Changelog for MishkaDeveloperTools 0.1.4

Features:

  guardedstruct do
    conditional_field(:actor, any()) do
      field(:actor, struct(), struct: Actor, derive: "validate(map, not_empty)")

      conditional_field(:actor, any(),
        structs: true,
        derive: "validate(list, not_empty, not_flatten_empty_item)"
      ) do
        field(:actor, struct(), struct: Actor, derive: "validate(map, not_empty)")

        field(:actor, String.t(), derive: "sanitize(tag=strip_tags) validate(url, max_len=160)")
      end

      field(:actor, String.t(), derive: "sanitize(tag=strip_tags) validate(url, max_len=160)")
    end
  end

Fixed bugs:

  • Fix showing different errors when they accompany a conditional errors
  • Fix short anonymous function warning in elixir 1.16
  • Support pre-check derives inside conditional fields
  • Normalize conditional fields errors
  • Normalize validator errors
  • Normalize errors hint
  • Normalize derives errors
  • Fix dialyzer warning
  • Support derive in normal conditional field without validator
conditional_field(:id, String.t()) do
  field(:id, String.t(), derive: "sanitize(tag=strip_tags) validate(url, max_len=160)")
  field(:id, any(), derive: "sanitize(tag=strip_tags) validate(not_empty_string, uuid)")
end

Docs

  • Add LiveBook

Run in Livebook


Github: Release 0.1.4 · mishka-group/mishka_developer_tools · GitHub
Hex: mishka_developer_tools | Hex

If you can contribute with me in this way, please contact me

shahryarjb

shahryarjb

We recently separated the GuardedStruct macro into a standalone library. Please visit its repository for more information.

The Mishka Developer Tools library became a place where I gradually added my helper tools, one of which was the GuardedStruct macro, which eventually became a fully independent and improved tool. I received two requests to separate this library, along with other reasons, such as deprecating many optional libraries that, if installed, provided an additional validation layer, like for location.

Now, all these optional libraries have been removed, and if you’d like to add custom validation, you can easily do so following the library’s documentation. Backward compatibility has also been fully considered, allowing you to use the package with ease.

Hex: guarded_struct | Hex

In the next version, I’ll publish a separate post for this library. If you were only using the GuardedStruct macro, you can remove Mishka Developer Tools and install the mentioned library instead.

Installation

def deps do
  [
    {:guarded_struct, "~> 0.0.1"}
  ]
end

Where Next?

Popular in Announcing Top

Flo0807
Hello everyone! I am excited to share our heart project Backpex with you. After building several Phoenix applications, we realized that...
New
kevinlang
Hey all, We have made an Ecto3 Adapter for SQLite3, ecto_sqlite3! We have successfully on-boarded the full suite of integration tests (...
New
ostinelli
Let’s write a database! Well not really, but I think it’s a little sad that there doesn’t seem to be a simple in-memory distributed KV da...
New
jakub-zawislak
Hi everyone, I’m coming from the Symfony (PHP) framework. I like Phoenix, but it has a one thing that was build much better in the Symfo...
New
bradley
I’ve been working with Claude Code extensively and absolutely love it. However, I’ve come across the challenge of managing configuration ...
New
mikehostetler
I’m excited to announce Jido, a framework providing foundational primitives for building autonomous agent systems in Elixir. While develo...
New
Eiji
ExApi is a library that I’m developing now and hope release soon This library will allow to: list all apis list all api implementation...
New
type1fool
WebAuthnLiveComponent WebAuthnComponents See this post about renaming the package. Passwordless authentication for Phoenix LiveView app...
New
sbs
Only 650 LOC, wrote for fun :slight_smile: https://github.com/sunboshan/qrcode
New
KronicDeth
Elixir plugin for JetBrain’s IntelliJ Platform (including Rubymine) This is a plugin that adds support for Elixir to JetBrains IntelliJ...
289 36432 110
New

Other popular topics Top

electic
Hi, I am new to Elixir. I am trying to use the DateTime component to insert a date into MySQL however the there seems to be no way to fo...
New
WestKeys
Currently suffering from paralysis by [HTTP client] analysis. This is rather unusual in Elixirland as there tends to be consensus on the ...
New
Emily
I have VueJS GUIs with the project generated using Webpack. I have Elixir modules that will need to be used by the VueJS GUIs. I forese...
New
jononomo
I am trying to figure out how Mix knows whether the environment is test, dev, or prod – where is this set? Thanks.
New
Lily
In templates/appointment/index.html.eex: <%= for appointment <- @appointments do %> <tr> <td><%= appoi...
New
freewebwithme
Using vs code and installed ElixirLS: support and debugger. And I got an error popped up on start up says Failed to run ‘elixir’ comma...
New
grych
Hi folks, Few months ago I have announced the proof-of-concept of the library to manipulate the browsers DOM objects directly from Elixi...
639 52774 488
New
ashish173
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
New
saif
Hello everyone, Long time lurker first time poster here. I’ve recently begun working on Elixir full-time again! :raised_hands: It’s been...
New
hariharasudhan94
Lets say I have map like this fetching from my database %{"_id" => #BSON.ObjectId<58eb1a7a9ad169198c3dXXXX>, "email" => ...
New

We're in Beta

About us Mission Statement