You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Feb 16, 2021. It is now read-only.
Presently there are a bunch of NODE_ENV checks which disable validation in production. As we're mostly using flow rather than tcomb specific checks this appears to be doing much the same as stripping the flow out. If some checking continues but is watered down for performance reasons we may not catch the logic switch upon production, and no documentation exists to explain it. We'd rather the logic was environment agnostic, settable by config.
Although we may not always want production validation (it could be per module based) we definitely need it for function input arguments, simply to cut down on manual typeof checks, thus as a starting point we need the NODE_ENV check to be configurable. The best means to do this I believe is by a flag on the library, which can additionally be set via a new .babelrc 'tcomb' plugin flag.
The text was updated successfully, but these errors were encountered:
We should make something like a big HINT sign in the docs, because this behaviour is only documented with one small sentence and completly caught me off guard, because the behaviour only occured in production.
I ended up using tcomb-validation and this function, to reproduce the same error throwing behaviour:
import*asTfrom'tcomb-validation';constthrowIfInvalidCreator=(type: T.Type)=>(value: any): any=>{constvalidation=T.validate(value,type);returnvalidation.isValid() ? value : T.fail(validation.firstError().message);};
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Presently there are a bunch of NODE_ENV checks which disable validation in production. As we're mostly using flow rather than tcomb specific checks this appears to be doing much the same as stripping the flow out. If some checking continues but is watered down for performance reasons we may not catch the logic switch upon production, and no documentation exists to explain it. We'd rather the logic was environment agnostic, settable by config.
Although we may not always want production validation (it could be per module based) we definitely need it for function input arguments, simply to cut down on manual typeof checks, thus as a starting point we need the NODE_ENV check to be configurable. The best means to do this I believe is by a flag on the library, which can additionally be set via a new .babelrc 'tcomb' plugin flag.
The text was updated successfully, but these errors were encountered: