-1

I am creating a new article node using DRUPAL 8 Rest api through postman. I am able able to create new node using url /entity/node/?_format=json.

My question is how can I by pass a mandatory field validation in Drupal 8?

  • 1
    Never had to deal with such scenario before. Here is what I would try. Make the field not required in the field's settings. Via hook_form_FORM_ID_alter make the field required. Hopefully this way will allow you to bypass it. – No Sssweat Aug 24 at 6:37
  • The only way I've found is to completely alter the core constraint plugin and provide my own. This is not ideal/dangerous because constraint plugins are used everywhere so altering it alters it for anything. It's one of the effects the otherwise good concept of decoupling had on field and field widget validation had on Drupal 8. – mradcliffe Aug 28 at 11:29
  • Thanks your for suggestions, mradcliffe I will try this. As of now I used @RestResource Plugins and extended the ResourceBase Class and override the post() method to achieve this. – nirmalya batabyal Aug 29 at 12:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.