dataffy / themis Goto Github PK
View Code? Open in Web Editor NEWThemis is a validation and processing library that helps you always make sure your data is correct.
License: ISC License
Themis is a validation and processing library that helps you always make sure your data is correct.
License: ISC License
Make the Validator
constructor public instead of protected.
The validator constructor is protected, and we always need to override it in the child validator
class MyValidator extends Validator<string> {
constructor() {
super();
}
}
.
class MySchema extends Schema {
@StringField({ validators: [new TimeZoneValidator()]})
myField: string
}
We are forced by typescript to override the constructor, because we cannot use new TimeZoneValidator()
, if the constructor is protected
Make the constructor public, so we don't need to override it.
The package has 3 levels of validations:
ValidateError
which has a messageValidateError
messages must be constructed and an ProcessorValidateError
is thrown with the arrayValidateError
Description
Add the EnumField
decorator and create the processor for the field.
The field's toInternalValue will transform the input string into the the Enum type and check if it is a valid value for the enum.
Configuration:
enum - The enum that you want the string to be checked against.
We should have a class PolymorphicSchema
which should have the following:
type
Description
Inherit the fields from all parent classes.
e.g:
class BaseSchema extends Schema<BasePayload> {
@StringField()
parentField: string;
}
class ChildSchema extends Schema<ChildPayload> {
@IntegerField()
extraField: string;
}
When the ChildSchema is validated, it should also validate the parentField
We need a function that saves the values that will we processed by Schema.
class Schema {
protected toInternalValue(date: T): C {
}
}
The nested fields configuration should stop using any.
export type NestedFieldConfiguration<T> = {
validator: any; //TODO: Update type
};
Nested validation does not call validate function from nested schema.
The field decorators need to allow the possibility to specify from where that field gets the value from the input data.
Example usage:
@StringField({fromField: 'last_name'})
lastName: string;
Description
Add the ArrayField decorator and create the processor for the field.
The field should allow specifying what is the child value that is going to be validated. It is either a primitive value (another field) or another schema.
Add the ability to input custom validators for fields that will not override the default preset validators but will be both applied.
const isValidString = (value: string) => !value.isEmpty()
@StringField({validators: [isValidString]})
Currently the processor are not converting the values from string to number.
Add the EmailField decorator and create the processor for the field.
Add the DateField decorator and create the processor for the field.
The field's toInternalValue
will transform the input string to a date format and check the formats allowed. If the value is a date, it doesn't need transforming anymore.
For working with date functions, add date-fns package
MM/dd/yyyy
)A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.