- deprecate:
schema.without()
, useschema.omit()
instead - feat: add
schema.partial()
to return a new schema with all fields optional - feat: add
schema.required()
to return a new schema with all fields required
- Added option
multipleOf: number
to schema fields - Added option
uniqueItems: boolean
to schema fields - Added options
minItems: number
andmaxItems: number
to schema fields - Fixed missing error throw when validation of a schema throws an unhandled error
- Fixed
instanceof FieldError
not working and other related bugs due to TypeScript compilation ( see https://github.com/Microsoft/TypeScript/wiki/FAQ#why-doesnt-extending-built-ins-like-error-array-and-map-work)
- Fixed "required field" error on nested attributes of an optional object when using
option
removeUnknown: true
- Upgraded dependencies
- Throw
FieldResolutionError
when path is not valid
- Added
FieldError
to exports
- Upgraded dependencies
- [BREAKING] Removed
Schema
from default package export (still available withimport { Schema } from '@jalik/schema'
) - [BREAKING] Removed
defaultValue
option fromSchemaField
definition - [BREAKING] Removed
nullable
option fromSchemaField
definition - [BREAKING] Renamed
setLocale()
tosetLocaleMessages()
- [BREAKING] From now, setting
required: true
on a field will throw an error withnull
values
- Added
isValid()
toSchema
instance - Added
isValid()
toSchemaField
instance - Allow passing context to field properties functions (ex:
field.isRequired(context)
)
- Upgraded dependencies
- Upgraded dependencies
- Added exports of error constants and locale functions in index.js
- Added locale "en" as a file to not rely on defaults ("en" still remains the default locale)
- Changed the default error messages to not contain the field name
- Fixed potential breaking "export from" syntax in main file (index.js)
- Upgraded dependencies
- Fixed imports in README.md
- Upgraded dependencies
- Fixed options passed to
Schema.getErrors()
being ignored
- Fixed checking of "date-time" format
- Fixed removing of unknown fields in nested array items when passing
removeUnknown: true
toSchema.validate()
- Fixed missing check of optional second fraction in
date-time
andtime
format - Added alias
date-time
fordatetime
format like in JSON Schema specification
- Upgraded dependencies
- Upgraded dependencies
- [BREAK] Method
getErrors()
ofSchema
returnsnull
instead of{}
if no errors - Added method
without(fieldNames)
toSchema
- Upgraded dependencies
- Upgraded dependencies
- Fixed missing french message for ERROR_FIELD_FORMAT
- Upgraded dependencies
DELETIONS
- [BREAK] Exports named function
contains()
in utils.js - [BREAK] Moves function
computeValue()
to utils.js - [BREAK] Removed attribute
context
on fields errors - [BREAK] Removed error reason
field-instance
- [BREAK] Removed method
isValid()
fromSchema
- [BREAK] Removed method
update()
inSchema
- [BREAK] Removed method
addField()
inSchema
- [BREAK] Removed method
getCheckFunction()
fromSchemaField
- [BREAK] Removed method
getCleanFunction()
fromSchemaField
- [BREAK] Removed method
getParseFunction()
fromSchemaField
- [BREAK] Removed method
getPrepareFunction()
fromSchemaField
- [BREAK] Removed option
decimal
inSchemaField
- [BREAK] Removed regexp
AlphaRegex
in regex.js - [BREAK] Removed regexp
AlphaNumericRegex
in regex.js - [BREAK] Removed regexp
ExtendedAlphaNumericRegex
in regex.js - [BREAK] Removed support for syntax
[min, max]
of optionlength
inSchemaField
MODIFICATIONS
- [BREAK] Changed array interpretation for option
type
inSchemaField
- [BREAK] Changed default value of option
nullable
tofalse
inSchemaField
- [BREAK] Changed default value of option
required
tofalse
inSchemaField
- [BREAK] Changed default value of options
clean
andparse
tofalse
inSchema.validate()
andSchemaField.validate()
- [BREAK] Changed parsing of
"boolean"
fields to returntrue
only if value istrue
( case-insensitive) - [BREAK] Renamed error reason
field-bad-value
tofield-allowed
- [BREAK] Renamed error reason
field-max-value
tofield-max
- [BREAK] Renamed error reason
field-min-value
tofield-min
- [BREAK] Renamed error reason
field-missing
tofield-required
- [BREAK] Renamed error reason
field-null
tofield-nullable
- [BREAK] Renamed error reason
field-regex
tofield-pattern
- [BREAK] Renamed file
schema.js
toSchema.js
- [BREAK] Renamed file
schema-field.js
toSchemaField.js
- [BREAK] Renamed method
getAllowedValues()
togetAllowed()
inSchemaField
- [BREAK] Renamed method
getDeniedValues()
togetDenied()
inSchemaField
- [BREAK] Renamed method
getMaxValue()
togetMax()
inSchemaField
- [BREAK] Renamed method
getMinValue()
togetMin()
inSchemaField
- [BREAK] Renamed option
regEx
topattern
inSchemaField
- [BREAK] Renamed regexp
EmailRegex
toEmailRegExp
in regex.js - [BREAK] Renamed regexp
FQDNRegex
toHostnameRegExp
in regex.js - [BREAK] Renamed regexp
IPv4Regex
toIPv4RegExp
in regex.js - [BREAK] Replaced type option
Array
by"array"
inSchemaField
- [BREAK] Replaced type option
Boolean
by"boolean"
inSchemaField
- [BREAK] Replaced type option
Number
by"number"
inSchemaField
- [BREAK] Replaced type option
String
by"string"
inSchemaField
- [BREAK] Throw
FieldTypeError
instead ofFieldInstanceError
- [BREAK] Throw
FieldTypeError
instead ofFieldValueTypesError
- Changed error messages
FIXES
- Return the cloned properties with
getProperties()
inSchemaField
- Return the cloned object with
clean()
inSchema
- Return the cloned object with
parse()
inSchema
- Return the cloned object with
removeUnknownFields()
inSchema
- Return the cloned object with
validate()
inSchema
- Return the parsed value of type
"boolean"
,"integer"
or"number"
ifparse
option is missing inSchemaField
- Throw an error when options
allowed
anddenied
are both defined inSchemaField
ADDITIONS
- Added attribute
errors
inValidationError
- Added attribute
path
inFieldError
- Added errors classes in
errors/*.js
(ex:errors/FieldRequiredError.js
) - Added errors constants in
errors.js
- Added function
getErrorMessage()
in locale.js - Added function
setLocale()
in locale.js - Added method
getErrors()
inSchema
- Added option
format
with accepted valuesdate
,datetime
,email
,hostname
,ipv4
,ipv6
,time
,uri
inSchemaField
- Added option
items
inSchemaField
to set constraints of array items - Added option
rootOnly
inSchemaField.validate()
to not check nested schemas - Added regexp
DateRegExp
in regex.js - Added regexp
DateTimeRegExp
in regex.js - Added regexp
TimeRegExp
in regex.js - Added support for dot syntax in field path (ex:
Schema.getField('profile.phones.number')
) - Added support for
"integer"
with optiontype
inSchemaField
- Added support for
String
with optionpattern
inSchemaField
- Added translation for french in
locales/fr.js
UPDATES
- Upgraded dependencies
- Upgraded dependencies
- Upgraded dependencies
- Upgraded dependencies
- Upgraded dependencies
- Lib available in ES6+ syntax (see
src
folder) to enable auto-completion in IDEs - Upgraded dependencies
- Upgraded dependencies
- Fixed error thrown for
maxLength
constraint
- Added method
SchemaField.getMaxLength()
- Added method
SchemaField.getMinLength()
- Added option
maxLength: Number or Function
toSchemaField(options)
- Added option
minLength: Number or Function
toSchemaField(options)
- Upgraded dependencies
- Upgraded dependencies
- Removed unused devDependencies
- Upgraded dependencies
- Added option
parse: Boolean
toSchema.validate(Object)
- Added method
Schema.parse(Object)
- Added method
SchemaField.getParseFunction()
- Added method
SchemaField.parse(String)
- Added option
parse: Function
toSchemaField
constructor - Fixed
Schema.removeUnknownFields()
to remove unknown nested fields
- Makes method
SchemaField.computeValue
static - Makes method
SchemaField.throwFieldBadValueError
static - Makes method
SchemaField.throwFieldDeniedValueError
static - Makes method
SchemaField.throwFieldInstanceError
static - Makes method
SchemaField.throwFieldLengthError
static - Makes method
SchemaField.throwFieldMaxLengthError
static - Makes method
SchemaField.throwFieldMaxValueError
static - Makes method
SchemaField.throwFieldMaxWordsError
static - Makes method
SchemaField.throwFieldMinLengthError
static - Makes method
SchemaField.throwFieldMinValueError
static - Makes method
SchemaField.throwFieldMinWordsError
static - Makes method
SchemaField.throwFieldMissingError
static - Makes method
SchemaField.throwFieldNullError
static - Makes method
SchemaField.throwFieldRegExError
static - Makes method
SchemaField.throwFieldTypeError
static - Makes method
SchemaField.throwFieldValueTypesError
static
- Exports
Schema
using ES6 default export - Exports
SchemaError
using ES6 default export - Exports
SchemaField
using ES6 default export
- Makes option
type: *
optional forSchemaField
constructor
- Added method
SchemaField.getPrepareFunction()
- Added option
prepare: Function
forSchemaField
constructor
- Added method
SchemaField.getName()
- Added method
SchemaField.throwFieldNullError()
- Uses return value of
SchemaField.validate()
to modify field value - Uses empty array
[]
as default value forArray
fields defined as required and non-null - Throw missing field error only when a required field is
undefined
(does not depend onnullable
option anymore)
- Fixed main file exports
- Fixed documentation for importing classes and methods
- Explodes classes in multiple files (see doc to import classes and methods)
- Added method
Schema.removeUnknownFields(obj)
- Added method
SchemaField.getAllowedValues()
- Added method
SchemaField.getCheckFunction()
- Added method
SchemaField.getCleanFunction()
- Added method
SchemaField.getDefaultValue()
- Added method
SchemaField.getDeniedValues()
- Added method
SchemaField.getLabel()
- Added method
SchemaField.getLength()
- Added method
SchemaField.getMaxValue()
- Added method
SchemaField.getMaxWords()
- Added method
SchemaField.getMinValue()
- Added method
SchemaField.getMinWords()
- Added method
SchemaField.getProperties()
- Added method
SchemaField.getRegEx()
- Added method
SchemaField.getType()
- Added method
SchemaField.isDecimal()
- Added method
SchemaField.isNullable()
- Added method
SchemaField.isRequired()
- Added field option
defaultValue
to set default value, works only if field is required but has its valueundefined
- Renamed method
SchemaField.dynamicValue()
toSchemaField.computeValue()
- The method
SchemaField.validate()
now returns the processed value (ex: default value or cleaned value) - Updates README.md
- Updates README.md
- Fixed console warning
Unknown property "field.name"
when assigning a name to a field
- Allows to use function for
decimal
,label
,nullable
andrequired
constructor options inSchemaField
- Changed error messages
- Added value as first argument of
check(value)
field property
- Fixed options
nullable
andrequired
inSchemaField
constructor
- Added class
SchemaField
- Added method
Schema.addField(name, props)
- Added method
Schema.clone()
- Added method
Schema.update(fields)
- Moves
Schema.cleanField()
toSchemaField.clean()
- Moves
Schema.dynamicValue()
toSchemaField.dynamicValue()
- Moves
Schema.validateField()
toSchemaField.validate()
- Added
resolveField(name)
method
- Added
getField(name)
method - Uses field name as first parameter of
validateField(name, value)
method instead of field properties
- Removed warning
Unknown property "${field}.label"
- Changed
schema.extend(fields)
signature, uses fields instead of parent schema
- Added
schema.extend(fields)
to create a schema based on an existing one - Added
schema.getFields()
to return schema fields - Added
schema.isValid(obj, options)
to validate an object without throwing an error - Added
nullable
field option to allow a field to benull
- Added
ignoreMissing
option toSchema.validate()
to ignore missing fields (useful for updates)
- First public release