Skip to content

Add flag validators #2

@yin

Description

@yin

GFlags uses Validators to quickly resolve any ill-formatted flag value with an application crash and a useful message. The validators are defined similarly to defining a flag and the two stay close together.

Consider following syntax:

    private static final Flag<Integer> angle = Flags.integer('angle')
        .validate(new Validator<Integer>() {
            @Override public boolean check(String flagName, Integer value) {
                return value >=0 && value < 360;
            }
        });

Java 8:

    private static final Flag<Integer> angle = Flags.integer('angle')
        .validate((flagName, value) -> value >=0 && value < 360);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions