Tips for creating a validator in elixir

It’s weekend, my country is on lockdown due to covid-19 and I am bored and I want to build a validator.

I am calling it a validator because I dont know the exact terminology for it (parser/linter).

I have a rails app that has a feature that produces a dynamic form by reading a yml file.

For eg:

- name: Personal Details
  - name: firstName
    type: text
    label: First Name

And it would produce html like

<div> Personal Details </div>

  <label> First Name </label>
  <input type="text" name="firstName">

I want to feed this yml file to my elixir app which will then check if the yml is correct. I mean, let’s say I missed to put label in the yml file and my elixir app should be able to detect that and warn the user, just like JSON linter.

So, can I use something like nimbel_parsec for this? And what is the right terminology for it(validator/linter/parser)?

The yml file will have to follow proper grammar for it to produce the html, so maybe it’s a parser?

gettext uses yecc

You can use yaml_elixir or yamerl to decode your yaml, and after that, you could use xema. I have nerver used yaml_elixir od yamerl and xema is a selfish personal ad.

1 Like