class ValidationResult {

    private boolean valid;
    private String message;
    private String code;

    public static ValidationResult ok() {
        return new ValidationResult(true, null, null);
    }

    public static ValidationResult ok(String code) {
        return new ValidationResult(true, null, code);
    }

    public static ValidationResult fail(String message) {
        return new ValidationResult(false, message, null);
    }

    public static ValidationResult fail(String code, String message) {
        return new ValidationResult(false, message, code);
    }

    public void throwIfInvalid() {
        this.throwMessage(getMessage());
    }

    public void throwIfInvalid(String fieldName) {<FILL_FUNCTION_BODY>}

    public <T, R> void throwIfInvalid(TypeFunction<T, R> function) {
        var fieldName = BladeKit.getLambdaFieldName(function);
        throwIfInvalid(fieldName);
    }

    public void throwMessage(String msg) {
        if (!isValid()) throw new ValidatorException(msg);
    }

}

        if (!isValid()) throw new ValidatorException(fieldName + " " + getMessage());
    
<no_super_class>