freddi301/flow-validator

View on GitHub
src/sync/Voptional.js

Summary

Maintainability
A
2 hrs
Test Coverage
// @flow

import { VType, VOptionalType } from "./VType";

export function Voptional<T>(t: VType<T>): VOptionalType<T> {
  return new VOptionalType(t, v => {
    if (v === null || v === void 0) return v;
    return t.validate(v);
  });
}