private void validate(final File filePath) {
        try {
            val basicFileAttributes = Files.readAttributes(filePath.toPath(), BasicFileAttributes.class);
            if (basicFileAttributes.isRegularFile() && filePath.exists()
                && filePath.canRead() && basicFileAttributes.size() > 0) {
                val validator = switch (FilenameUtils.getExtension(filePath.getPath()).toLowerCase(Locale.ENGLISH)) {
                    case "yml", "yaml" -> new RegisteredServiceYamlSerializer(applicationContext);
                    default -> new RegisteredServiceJsonSerializer(applicationContext);
                };
                val svc = Objects.requireNonNull(validator).from(filePath);
                LOGGER.info("Service [{}] is valid at [{}].", svc.getName(), filePath.getCanonicalPath());
            } else {
                LOGGER.warn("File [{}] is does not exist, is not readable or is empty", filePath.getCanonicalPath());
            }
        } catch (final Exception e) {
            LOGGER.error("Could not understand and validate [{}]: [{}]", filePath.getPath(), e.getMessage());
        } finally {
            LOGGER.info("-".repeat(SEP_LINE_LENGTH));
        }
    }
Validate service.

@param file      the file
@param directory the directory
support/cas-server-support-shell-core/src/main/java/org/apereo/cas/shell/commands/services/ValidateRegisteredServiceCommand.java