code: public void validate(final ValidationContext context) {
          if (!context.getUserEvent().equalsIgnoreCase("submit")) {
              return;
          }
  
          val messages = context.getMessageContext();
          ApplicationContextProvider.getCasConfigurationProperties().ifPresent(props -> {
              if (StringUtils.isBlank(source) && props.getAuthn().getPolicy().isSourceSelectionEnabled()) {
                  messages.addMessage(new MessageBuilder()
                      .error()
                      .source("source")
                      .code("source.required")
                      .build());
              }
          });
      }
docs: Validate.
  
  @param context the context