summaryrefslogtreecommitdiff
path: root/src/test/java/com/beust/jcommander/ArgsValidate2.java
blob: f45f5df2757717e43c8df7ad3d57bb7f9f31d2df (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
package com.beust.jcommander;

import com.beust.jcommander.converters.FileConverter;

import java.io.File;

public class ArgsValidate2 {
  public static class FailingValidator implements IParameterValidator {

    public void validate(String name, String value) throws ParameterException {
      throw new ParameterException("Validation will always fail:" + name + " " + value);
    }
    
  }

  public static final String POSSIBLE_TEMPLATE_FILE = "mayOrMayNotExist.tempalate";

  @Parameter(names = { "-template"},
      description = "The default file may or may not exist",
      converter = FileConverter.class, 
      validateWith = FailingValidator.class
      )
  public File template = new File(POSSIBLE_TEMPLATE_FILE);
}