Skip to content
This repository has been archived by the owner on Mar 16, 2023. It is now read-only.

Commit

Permalink
feat: numberField allow null or undef
Browse files Browse the repository at this point in the history
  • Loading branch information
hanayashiki committed Mar 8, 2022
1 parent abede45 commit 08fded8
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
9 changes: 4 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@
"url": "https://github.com/MonoidDev/reform"
},
"private": false,
"version": "1.0.0-alpha.0",
"version": "1.0.1",
"license": "MIT",
"publishConfig": {
"access": "public"
},
"main": "./dist/cjs/index.cjs",
"module": "./dist/esm/index.mjs",
"typesVersions": {
"*": {
"*": [
">=4.2": {
".": [
"src/index.ts"
],
"react": [
Expand All @@ -42,11 +42,10 @@
"node": ">=10"
},
"scripts": {
"postinstall": "husky install",
"build": "node ./esbuild.js",
"dev": "node ./esbuild.js --watch",
"lint": "prettier --check src/",
"prepare": "yarn build",
"prepare": "husky install && yarn build",
"size": "size-limit",
"analyze": "size-limit --why",
"test": "yarn jest"
Expand Down
5 changes: 4 additions & 1 deletion src/fields/numberField.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ export const numberField = (
const { message } = options;

const numberType = any().refine((input) => {
if (typeof input === 'string' && input.trim().length === 0) {
if (
(typeof input === 'string' && input.trim().length === 0) ||
input == null
) {
return makeRight(undefined);
}

Expand Down
2 changes: 2 additions & 0 deletions src/types/infer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import { Resolver } from './Resolver';

export type AnyResolver = Resolver<any, any, any, string>;

export type UnknownResolver = Resolver<unknown, unknown, unknown, string>;

export type ResolverMap = {
[K in string]: AnyResolver;
};
Expand Down

0 comments on commit 08fded8

Please sign in to comment.