code: final protected function addRequiredAttributeToFields(array $specifications)
      {
          /** @var array $data */
          foreach ($specifications as $field => $data) {
              if (!$this->has($field)) {
                  continue;
              }
  
              $validators = ArrayUtils::get($data, 'validators', []);
              $isRequired = (bool) ArrayUtils::get(
                  $data,
                  'required',
                  ArrayUtils::get($validators, NotEmpty::class, ArrayUtils::get($validators, 'NotEmpty'))
              );
  
              if ($isRequired) {
                  $this->get($field)->setAttribute('required', 'required');
              }
          }
  
          return $this;
      }
docs: Add attributes to required fields.
  
  @param array $specifications
  
  @return $this
  @throws \Xloit\Std\Exception\RuntimeException