sradevski / aida

Unified data modeling

Home Page:https://sradevski.com/aida

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Create validation injector

sradevski opened this issue · comments

Libraries that can be used internally for validation:

The validator can accept an array of "types" like unique, id, or custom validation functions.

General flow:

  • Get the hash value of each validation function.toString(), and store it in an object such as
const validators = {
[hashval]: () => null,
}
  • Iterate over each object in each definition
  • Get the validation function
  • If it is string, replace it with the hashval for that pre-defined function
  • If it is a function get the hash value of that function.toString(), add it to the rest of validators and replace it with the hash value.
  • At the end, you can potentially remove the unused pre-defined functions, but it is not necessary for a start.
  • Once all validators are generated, output them to a file exported as an object as the validators object above
  • In a separate file, create the validation executor which will be the connection between the validator functions and the hash value for each field in each definition.