-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
BREAKING CHANGE: Use named exports instead of single exported object. Replace: import clean from "data-cleaner" with: import * as clean from "data-cleaner" Refs #7
- Loading branch information
1 parent
037e709
commit b42a23a
Showing
12 changed files
with
37 additions
and
97 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,73 +1,19 @@ | ||
// My original intent was to export default cleaners to be universally and easily used in CJS, ES6 and TS | ||
|
||
// However, with simple exports (commented below) this will not work in TS: | ||
// import clean from 'data-cleaner' | ||
// insead, one will need to write: | ||
// import * as clean from 'data-cleaner' | ||
// which is not what I want. | ||
|
||
// -------------------------------------- | ||
|
||
// export { default as any, AnySchema } from './cleaners/any' | ||
// export { default as string, StringSchema } from './cleaners/string' | ||
// export { default as date, DateSchema } from './cleaners/date' | ||
// export { default as integer, IntegerSchema } from './cleaners/integer' | ||
// export { default as float, FloatSchema } from './cleaners/float' | ||
// export { default as boolean, BooleanSchema } from './cleaners/boolean' | ||
// export { default as array, ArraySchema } from './cleaners/array' | ||
// export { default as object, ObjectSchema } from './cleaners/object' | ||
|
||
// export { SchemaError } from './errors/SchemaError' | ||
// export { ValidationError } from './errors/ValidationError' | ||
|
||
// export { CleanerOptions, Cleaner } from './types' | ||
|
||
// -------------------------------------- | ||
|
||
// So for the time being I ended up with this: | ||
|
||
import cleanAny from './cleaners/any' | ||
import cleanString from './cleaners/string' | ||
import cleanDate from './cleaners/date' | ||
import cleanEmail from './cleaners/email' | ||
import cleanInteger from './cleaners/integer' | ||
import cleanFloat from './cleaners/float' | ||
import cleanBoolean from './cleaners/boolean' | ||
import cleanArray from './cleaners/array' | ||
import cleanObject from './cleaners/object' | ||
import { SchemaError } from './errors/SchemaError' | ||
import { ValidationError } from './errors/ValidationError' | ||
|
||
export default { | ||
any: cleanAny, | ||
string: cleanString, | ||
date: cleanDate, | ||
email: cleanEmail, | ||
integer: cleanInteger, | ||
float: cleanFloat, | ||
boolean: cleanBoolean, | ||
array: cleanArray, | ||
object: cleanObject, | ||
// TODO: convert the below to named exports?? | ||
SchemaError, | ||
ValidationError, | ||
} | ||
|
||
// Export types as named exports. | ||
// Unlike exporting of values, this does not break CJS/ES6 default export. | ||
|
||
export { Cleaner } from './types' | ||
export { AnySchema } from './cleaners/any' | ||
export { StringSchema } from './cleaners/string' | ||
export { DateSchema } from './cleaners/date' | ||
export { EmailSchema } from './cleaners/email' | ||
export { IntegerSchema } from './cleaners/integer' | ||
export { FloatSchema } from './cleaners/float' | ||
export { BooleanSchema } from './cleaners/boolean' | ||
export { ArraySchema } from './cleaners/array' | ||
export { ObjectSchema } from './cleaners/object' | ||
|
||
export { cleanAny as any, AnySchema } from './cleaners/any' | ||
export { cleanArray as array, ArraySchema } from './cleaners/array' | ||
export { cleanBoolean as boolean, BooleanSchema } from './cleaners/boolean' | ||
export { cleanDate as date, DateSchema } from './cleaners/date' | ||
export { cleanEmail as email, EmailSchema } from './cleaners/email' | ||
export { cleanFloat as float, FloatSchema } from './cleaners/float' | ||
export { cleanInteger as integer, IntegerSchema } from './cleaners/integer' | ||
export { cleanObject as object, ObjectSchema } from './cleaners/object' | ||
export { cleanString as string, StringSchema } from './cleaners/string' | ||
|
||
export { SchemaError } from './errors/SchemaError' | ||
export { | ||
ErrorMessage, | ||
ErrorMessages, | ||
FieldErrorMessages, | ||
ValidationError, | ||
} from './errors/ValidationError' |