Skip to content

Add flag validators #2

Open
Open

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);

Activity

  1. yin commented on Aug 8, 2017

    @yin
    OwnerAuthor

    Done in v0.3.0-beta1

  2. yin commented on Aug 9, 2017

    @yin
    OwnerAuthor

    Missing tests, reopened

  3. reopened this on Aug 9, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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