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.9
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

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 Libraries Top

sasajuric
I’d like to announce a small library called boundaries. This is an experimental project which explores the idea of enforcing boundaries ...
New
mindok
What is ContEx? A pure Elixir server-side data plotting/charting library outputting SVG. It has nice barcharts in particular and works g...
New
danschultzer
In short Plug n’ play OAuth 2.0 provider library. Just set up a resource owner schema with Ecto (your user schema), install the dependen...
New
Antrater
Hi everyone! I’m thrilled to announce a huge thing. We have been developing Elixir Moon Design System for quite a while. We are finally ...
New
wmnnd
Hi there, for my project DBLSQD, I needed a file storage solution that is a bit more flexible than Arc. Because I thought others might f...
New
msaraiva
Surface is an experimental library built on top of Phoenix LiveView and its new LiveComponent API that aims to provide a more declarative...
564 42633 214
New
wojtekmach
Hey everyone! Req is an HTTP client for Elixir that I’ve been working on for quite some time. There is already a lot of HTTP clients out...
New
bluzky
You may know https://ui.shadcn.com/, a UI component library for React. I really love it’s design style and components. I’ve built some co...
381 12391 119
New
mplatts
With HEEX released we decided to start a components library using Tailwind CSS - check it out here: Petal Components. We also have a boi...
New
New

Other popular topics Top

sorentwo
Hello! tl;dr Announcing Oban, an Ecto based job processing library with a focus on reliability and historical observability. After spen...
977 41022 311
New
openscript
Hello! Sorry for this astonishing simple question, but I’m really stuck. I try to set up the intellij-elixir plugin, but I don’t know ho...
New
AstonJ
You’re a programmer, so you don’t need spoon feeding with the conventional drivel about “this is an integer.” No. You need to know what’s...
New
vac
Hi, I'm quite new in Elixir and I'm trying to format a string to a PEM format. I have the certificate value like MIIDBTCCAe2...... and ...
New
chrismccord
As promised, the first release candidate of Phoenix 1.3.0 is out! This release focuses on code generators with improved project structure...
New
mgjohns61585
Could someone help me? I'm making my first elixir program, number guessing game. I can't figure out how to convert the user's guess from ...
New
danschultzer
None of the current solutions worked well for me, so I went ahead and built a user management system from scratch. This project took far...
548 27727 240
New
fireproofsocks
Forgive me if this is obvious, but how does one delete a database record WITHOUT selecting it first? https://hexdocs.pm/ecto/Ecto.Repo.h...
New
Fl4m3Ph03n1x
About me? ( if you have nothing better to do than reading about some random guy in the internet :stuck_out_tongue: ) Hello all, this is ...
New
aesmail
Hello guys, I have finally made it. I created an admin interface for a framework. It’s been on my todo list for years and with the curre...
New

Sub Categories:

We're in Beta

About us Mission Statement