Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add API allowing plugins to declare the current action invalid #962

Closed
delucis opened this issue Jul 19, 2021 · 0 comments · Fixed by #963
Closed

Add API allowing plugins to declare the current action invalid #962

delucis opened this issue Jul 19, 2021 · 0 comments · Fixed by #963
Labels

Comments

@delucis
Copy link
Member

delucis commented Jul 19, 2021

Currently we support returning INVALID_MOVE from moves to bail out of a state update. There are circumstances where a plugin might also want to flag that an action is invalid. For example, a plugin that validates state or — as came up in #957 (review) — in the events plugin if there is an error processing the event queue.

This would probably look something like the current noClient plugin method. A plugin could declare an isInvalid method that could return any truthy value to invalidate the current action.

const plugin = {
  name: 'validator',
  isInvalid: ({ G }) => {
    if (typeof G.value !== number) {
      return { error: 'G.value must be a number' };
    }
  },
};

Once we have something like #723, plugin errors could be added to the possible error types and the return value of isInvalid returned to the client for debugging.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant