1 /*
2 * Copyright 2010-2020 Redgate Software Ltd
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16 package org.flywaydb.core.internal.configuration;
17
18 import org.flywaydb.core.api.ErrorCode;
19 import org.flywaydb.core.api.FlywayException;
20 import org.flywaydb.core.api.configuration.Configuration;
21
22 public class ConfigurationValidator {
23 public void validate(Configuration configuration) {
24
25
26
27
28
29
30
31
32
33 if (configuration.getDataSource() == null) {
34 throw new FlywayException(
35 "Unable to connect to the database. Configure the url, user and password!",
36 ErrorCode.CONFIGURATION);
37 }
38
39 for (String key : configuration.getPlaceholders().keySet()) {
40 if (key.toLowerCase().startsWith("flyway:")) {
41 throw new FlywayException("Invalid placeholder ('flyway:' prefix is reserved): " + key);
42 }
43 }
44 }
45 }