Skip to content

zen-lang/zen-gen

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation


Logo

ZENGEN

Random Data Generator based on zen schemes

Examples

Create a schema describing the human's name

 ;; zrc/example/core.edn
{ns example.core

 HumanName
 {:zen/tags #{zen/schema}
  :type     zen/map
  :keys     {:family {:type zen/string}
             :given  {:type zen/vector :every {:type zen/string}}}}

Generate data based on the above scheme

(ns example.core)

;; Initializing zen context
(def ztx (zen.core/new-context {:paths ["zrc"]}))
(zen.core/read-ns ztx 'example.core)

;; Data generation
(zengen.core/example ztx {:confirms #{example.core/HumanName})
;; =>
;; {:given  ["$QGn?DBRxM_JEB2" "6pMkz"]
;;  :family "sJr)y"}

Sometimes it is necessary to generate human-readable data

Let's declare the configuration with the tag zenden.core/definition and use the prepared data set from zenden.dataset

;; zrc/example/definitions.edn
{ns example.definitions
 import #{example.core
          zengen.core
          zengen.dataset.human.firstname
          zengen.dataset.human.lastname}

 GeneratorHumanName
 {:zen/tags #{zengen.core/definition}
  :options  
  {[example.core/HumanName :family]    {:confirms #{zengen.dataset.human.lastname/english}}
   [example.core/HumanName :given  :#] {:confirms #{zengen.dataset.human.firstname/english}}}}}}}
(zengen.core/initialize ztx)
(zengen.core/example ztx {:confirms #{example.core/HumanName})
;; =>
;; {:given  ["Gussie"]
;;  :family "Wright"}

For an example of a zengen.dataset.human.prefix schema:

{ns zengen.dataset.human.prefix

 english
 {:zen/tags #{zen/schema}
  :enum     [{:value "La"}
             {:value "De"}]}}

Acknowledgments

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published