samedi 22 mai 2021

How to blacklist certain character combinations from long text input using validations?

In my Rails app users can create their own email templates. I need to validate that only certain placeholders can be used, like to:

Dear {first_name} {last_name},

Please find enclosed our quote.

Best regards

John Doe

Bogus placeholders like {middle_name} or {foo} or even single brackets like { or } should be marked as invalid.

How can this be done using Ruby or Regex?

Aucun commentaire:

Enregistrer un commentaire