Skip to content

Commit

Permalink
VIP - Add README
Browse files Browse the repository at this point in the history
  • Loading branch information
shahryarjb committed Nov 1, 2024
1 parent 77b8017 commit 93e604a
Show file tree
Hide file tree
Showing 10 changed files with 2,615 additions and 29 deletions.
59 changes: 51 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,64 @@
# GuardedStruct

**TODO: Add description**
The creation of this macro will allow you to build `Structs` that provide you with a number of important options, including the following:

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

Suppose you are going to collect a number of pieces of information from the user, and before doing anything else, you are going to sanitize them.
After that, you are going to validate each piece of data, and if there are no issues, you will either display it in a proper output or save it somewhere else.
All of the characteristics that are associated with this macro revolve around cleaning and validating the data.

The features that we list below are individually based on a particular strategy and requirement, but thankfully, they may be combined and mixed in any way that you see fit.

It bestows to you a significant amount of authority in this sphere.
After the initial version of this macro was obtained from the source of the `typed_struct` library, many sections of it were rewritten, or new concepts were taken from libraries in Rust and Scala and added to this library in the form of Elixir base.

The initial version of this macro can be found in the `typed_struct` library. Its base is a syntax that is very easy to comprehend, especially for non-technical product managers, and highly straightforward.

Before explaining the copyright, I must point out that the primary library, which is `typed_struct`, is no longer supported for a long time, so please pay attention to the following copyright.

If [available in Hex](https://hex.pm/docs/publish), the package can be installed
by adding `guarded_struct` to your list of dependencies in `mix.exs`:
[![Run in Livebook](https://livebook.dev/badge/v1/pink.svg)](https://livebook.dev/run?url=https%3A%2F%2Fgithub.com%2Fmishka-group%2Fguarded_struct%2Fblob%2Fmaster%2Fguidance%2Fguarded-struct.livemd)

## Installation

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

Documentation can be generated with [ExDoc](https://github.com/elixir-lang/ex_doc)
and published on [HexDocs](https://hexdocs.pm). Once published, the docs can
be found at <https://hexdocs.pm/guarded_struct>.
## Table of Contents

* [Defines a guarded struct](https://github.com/mishka-group/guarded_struct/blob/master/guidance/guarded-struct.md#defines-a-guarded-struct)
* [Defining a struct layer without additional options](https://github.com/mishka-group/guarded_struct/blob/master/guidance/guarded-struct.md#defining-a-struct-layer-without-additional-options)
* [Define a struct with settings related to essential keys or `opaque` type](https://github.com/mishka-group/guarded_struct/blob/master/guidance/guarded-struct.md#define-a-struct-with-settings-related-to-essential-keys-or-opaque-type)
* [Defining the struct by calling the validation module or calling from the module that contains the struct](https://github.com/mishka-group/guarded_struct/blob/master/guidance/guarded-struct.md#defining-the-struct-by-calling-the-validation-module-or-calling-from-the-module-that-contains-the-struct)
* [Define the struct by calling the `main_validator` for full access on the output](https://github.com/mishka-group/guarded_struct/blob/master/guidance/guarded-struct.md#define-the-struct-by-calling-the-main_validator-for-full-access-on-the-output)
* [Define struct with `derive`](https://github.com/mishka-group/guarded_struct/blob/master/guidance/guarded-struct.md#define-struct-with-derive)
* [Extending `derive` section](https://github.com/mishka-group/guarded_struct/blob/master/guidance/guarded-struct.md#extending-derive-section)
* [Struct definition with `validator` and `derive` simultaneously](https://github.com/mishka-group/guarded_struct/blob/master/guidance/guarded-struct.md#struct-definition-with-validator-and-derive-simultaneously)
* [Define a nested and complex struct](https://github.com/mishka-group/guarded_struct/blob/master/guidance/guarded-struct.md#define-a-nested-and-complex-struct)
* [Error and data output sample](https://github.com/mishka-group/guarded_struct/blob/master/guidance/guarded-struct.md#error-and-data-output-sample)
* [Set config to show error inside `defexception`](https://github.com/mishka-group/guarded_struct/blob/master/guidance/guarded-struct.md#error-and-data-output-sample)
* [Error `defexception` modules](https://github.com/mishka-group/guarded_struct/blob/master/guidance/guarded-struct.md#error-defexception-modules)
* [`authorized_fields` option to limit user input](https://github.com/mishka-group/guarded_struct/blob/master/guidance/guarded-struct.md#authorized_fields-option-to-limit-user-input)
* [List of structs](https://github.com/mishka-group/guarded_struct/blob/master/guidance/guarded-struct.md#list-of-structs)
* [Struct information function](https://github.com/mishka-group/guarded_struct/blob/master/guidance/guarded-struct.md#struct-information-function)
* [Transmitting whole output of builder function to its children](https://github.com/mishka-group/guarded_struct/blob/master/guidance/guarded-struct.md#transmitting-whole-output-of-builder-function-to-its-children)
* [Auto core key](https://github.com/mishka-group/guarded_struct/blob/master/guidance/guarded-struct.md#auto-core-key)
* [On core key](https://github.com/mishka-group/guarded_struct/blob/master/guidance/guarded-struct.md#on-core-key)
* [From core key](https://github.com/mishka-group/guarded_struct/blob/master/guidance/guarded-struct.md#from-core-key)
* [Domain core key](https://github.com/mishka-group/guarded_struct/blob/master/guidance/guarded-struct.md#domain-core-key)
* [Domain core key with `equal` and `either` support](https://github.com/mishka-group/guarded_struct/blob/master/guidance/guarded-struct.md#domain-core-key-with-equal-and-either-support)
* [Domain core key with Custom function support](https://github.com/mishka-group/guarded_struct/blob/master/guidance/guarded-struct.md#domain-core-key-with-custom-function-support)
* [Conditional fields](https://github.com/mishka-group/guarded_struct/blob/master/guidance/guarded-struct.md#conditional-fields)
* [List Conditional fields](https://github.com/mishka-group/guarded_struct/blob/master/guidance/guarded-struct.md#list-conditional-fields)



The docs can be found at https://hexdocs.pm/guarded_struct.
Loading

0 comments on commit 93e604a

Please sign in to comment.