alchemy_cms
https://github.com/magiclabs/alchemy_cms
Ruby
AlchemyCMS is a powerful, flexible and user centric Rails 5 CMS. 🧙🏻♂️
Alchemy::Essence::InstanceMethods#validate_ingredient
Essence Validations:
Essence validations can be set inside the config/elements.yml file.
Supported validations are:
* presence
* uniqueness
* format
format needs to come with a regex or a predefined matcher string as its value.
There are already predefined format matchers listed in the config/alchemy/config.yml file.
It is also possible to add own format matchers there.
Example of format matchers in config/alchemy/config.yml:
format_matchers:
email: !ruby/regexp '/\A[^@\s]+@([^@\s]+\.)+[^@\s]+\z/'
url: !ruby/regexp '/\A[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(:[0-9]{1,5})?(\/.*)?\z/ix'
ssl: !ruby/regexp '/https:\/\/[\S]+/'
Example of an element definition with essence validations:
- name: person
contents:
- name: name
type: EssenceText
validate: [presence]
- name: email
type: EssenceText
validate: [format: 'email']
- name: homepage
type: EssenceText
validate: [format: !ruby/regexp '^[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(:[0-9]{1,5})?(\/.*)?$']
Example of an element definition with chained validations.
- name: person
contents:
- name: name
type: EssenceText
validate: [presence, uniqueness, format: 'name']Edit
git clone [email protected]:magiclabs/alchemy_cms.git
cd alchemy_cms
open lib/alchemy/essence.rb
Contribute
# Make a new branchgit checkout -b -your-name--update-docs-Alchemy--Essence--InstanceMethods-validate_ingredient-for-pr
# Commit to gitgit add lib/alchemy/essence.rbgit commit -m "better docs for Alchemy::Essence::InstanceMethods#validate_ingredient"
# Open pull requestgem install hub # on a mac you can `brew install hub`
hub fork
git push <your name> -your-name--update-docs-Alchemy--Essence--InstanceMethods-validate_ingredient-for-pr
hub pull-request
# Celebrate!