Change record status: 
Project: 
Introduced in branch: 
10.3.x
Introduced in version: 
10.3.0
Description: 

A new config schema data type, called bytes, has been added to core. As the name suggests, this constraint can be used to indicate that not just any string is allowed, but a string expressing a number of bytes: 5 MB, 10 gigabytes, etc.

This uses the existing \Drupal\Component\Utility\Bytes infrastructure in Drupal core.

The default validation constraints can be found in the definition of the new bytes data type:

# A number of bytes; either a plain number or with a size indication such as "MB".
# @see \Drupal\Component\Utility\Bytes
bytes:
  type: string
  label: 'Bytes'
  constraints:
    Callback: ['\Drupal\Component\Utility\Bytes', 'validateConstraint']

How to use?

Generally speaking:

Before
  mapping:
    max_size:
      type: string
      label: 'Maximum file size'
After
  mapping:
    max_size:
      # @see \Drupal\file\Plugin\Validation\Constraint\FileSizeLimitConstraintValidator
      type: bytes
      label: 'Maximum file size'
      nullable: true
Impacts: 
Module developers