I can't set a default value on hook_form_alter() I have form alter for the user_register_form which is called.
In this hook, I try to set a default value for a textfield but it doesn't work.
I've tried all the syntax possible #default_value, #value, value, default_value, event in the attributes array.

This is my code.

function pre_registration_form_user_register_form_alter(&amp;$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id) {
  $form['field_code_postal']['#cache']['max-age'] = 0;
  $form['field_code_postal']['#default_value'] = 'COUCOU';
  $form['field_code_postal']['#value'] = 'COUCOU';
  $form['field_code_postal']['value'] = 'COUCOU';
  $form['field_code_postal']['value']['#value'] = 'COUCOU';
  $form['field_code_postal']['value']['#default_value'] = 'COUCOU';
  $form['field_code_postal']['value']['value'] = 'COUCOU';
  $form['field_code_postal']['value']['default_value'] = 'COUCOU';
  $form['field_code_postal']['default_value'] = 'COUCOU';

  $form['field_code_postal']['#attributes']['value'] = 'COUCOU1';
  $form['field_code_postal']['#attributes']['#value'] = 'COUCOU2';
  $form['field_code_postal']['#attributes']['default_value'] = 'COUCOU3';
  $form['field_code_postal']['#attributes']['#default_value'] = 'COUCOU4';
}


How can I set a default value?
According to this Documentation you can do something like  

 $form['field_code_postal']['widget'][0]['value']['#default_value'] ='COUCOU1';


and for another guys help if you want to fill entity referenced field( also files are entity in drupal 8) use 

 $form['field_image']['widget'][0]['target_id']['#default_value']= $file; //