Skip to content

Commit

Permalink
fix: coarce -> coerce (#1677)
Browse files Browse the repository at this point in the history
  • Loading branch information
karlhorky committed May 31, 2022
1 parent ae69c88 commit 99aa257
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/boolean.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export default class BooleanSchema<

this.withMutation(() => {
this.transform((value, _raw, ctx) => {
if (ctx.spec.coarce && !ctx.isType(value)) {
if (ctx.spec.coerce && !ctx.isType(value)) {
if (/^(true|1)$/i.test(String(value))) return true;
if (/^(false|0)$/i.test(String(value))) return false;
}
Expand Down
2 changes: 1 addition & 1 deletion src/date.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export default class DateSchema<

this.withMutation(() => {
this.transform((value, _raw, ctx) => {
if (!ctx.spec.coarce || ctx.isType(value)) return value;
if (!ctx.spec.coerce || ctx.isType(value)) return value;

value = isoParse(value);

Expand Down
2 changes: 1 addition & 1 deletion src/number.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export default class NumberSchema<

this.withMutation(() => {
this.transform((value, _raw, ctx) => {
if (!ctx.spec.coarce) return value;
if (!ctx.spec.coerce) return value;

let parsed = value;
if (typeof parsed === 'string') {
Expand Down
4 changes: 2 additions & 2 deletions src/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import toArray from './util/toArray';
import cloneDeep from './util/cloneDeep';

export type SchemaSpec<TDefault> = {
coarce: boolean;
coerce: boolean;
nullable: boolean;
optional: boolean;
default?: TDefault | (() => TDefault);
Expand Down Expand Up @@ -170,7 +170,7 @@ export default abstract class Schema<
recursive: true,
nullable: false,
optional: true,
coarce: true,
coerce: true,
...options?.spec,
};

Expand Down
2 changes: 1 addition & 1 deletion src/string.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export default class StringSchema<

this.withMutation(() => {
this.transform((value, _raw, ctx) => {
if (!ctx.spec.coarce || ctx.isType(value)) return value;
if (!ctx.spec.coerce || ctx.isType(value)) return value;

// don't ever convert arrays
if (Array.isArray(value)) return value;
Expand Down

0 comments on commit 99aa257

Please sign in to comment.