Verified Commit a0466c55 authored by Alex Pott's avatar Alex Pott
Browse files

Issue #3457766 by narendraR, smustgrave: Add validation constraints to language.entity.*

parent 900d64b9
Loading
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -87,16 +87,28 @@ language.mappings:
language.entity.*:
  type: config_entity
  label: 'Language'
  constraints:
    FullyValidatable: ~
  mapping:
    id:
      type: string
      label: 'ID'
      constraints:
        NotBlank: []
        Regex:
          # @see \Drupal\Core\Language\LanguageInterface::VALID_LANGCODE_REGEX
          pattern: '/[a-zA-Z]{1,8}(-[a-zA-Z0-9]{1,8})*/'
          message: 'This is not a valid language code.'
    label:
      type: required_label
      label: 'Label'
    direction:
      type: string
      label: 'Direction'
      constraints:
        # @see \Drupal\Core\Language\LanguageInterface::DIRECTION_LTR and
        # \Drupal\Core\Language\LanguageInterface::DIRECTION_RTL
        Choice: [ 'ltr', 'rtl' ]
    weight:
      type: weight
      label: 'Weight'