0

I created a /config/schema/drupolo.yml file with the following content.

drupolo.social_network.setting: 
  type: config_object 
  label: 'Sacd Menu module settings.'
  mapping:
    facebook_page:
      type: string #Type: can be string | integer |  boolean
      label: 'Facebook page'
    twiiter_page:
      type: string
      label: 'Twitter page'

I created the /config/install/drupolo.social_network.setting.yml file with a key that doesn't exist in the schema file.

The problem is that the module is installed and the configuration is stored in the configuration table, and it doesn't respect the schema file.

facebook_page: 'https://facebook.com/default'
twitter_page: 'https://twiiter.com/default'
linkedn_page: 'http://linkedin.com' # key that don't respect the "drupolo.social_network.setting" structure that has been declared in the drupolo.yml

What is the purpose of the /config/schema/{module}.yml file if the config/install won't respect that structure?

1 Answer 1

1

Drupal does not check the configuration schema at runtime when the configuration is loaded - the configuration is assumed to be correct.

The schema is used in the tests - when running tests, configurations are automatically validated against the schema to ensure they are correct. Presumably you have developed your module with tests, and by the time you make your module publicly available you will have your tests running and verifying that the configurations you are shipping are valid.

The contributed config_inspector module is very useful for validating and debugging configuration and configuration schema.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.