How to validate a custom widget? I have created a custom widget that I would like to add some validation to. Specifically, if the widget is marked as required, to check that it actually has a value entered. I figure this should be pretty straight forward but Googling isn't returning any results that I am looking for. Probably using the wrong search terms. If someone can provide a link on how to do this or provide some hints that would be great!

Thanks.
For a form API element, just set $form['element']['#required'] = TRUE;

More info: #required


  Indicates whether or not the element is required. This
  automatically validates for empty fields, and flags inputs as
  required.


For more control, consider an #element_validate handler

Note, for a custom element using hook_element_info, #validate and #element_validate callback handlers are supported there in the element definition.