-
Notifications
You must be signed in to change notification settings - Fork 89
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Type defs for custom validation, fixes. #122
Conversation
@icebob in source code i found |
sanitized & source are used internally only. |
@akazakou could you review, plz? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@FFKL thank you for your PR. It mostly looks good to me, but I have a few questions
index.d.ts
Outdated
customs: { [ruleName: string]: { schema: RuleCustom, messages: MessagesType } } | ||
} | ||
|
||
type CheckerFunction = (value: unknown, schema: ValidationSchema, path: string, parent: object | null, context: Context) => true | ValidationError[]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CheckerFunction
should have a generic type for value
parameter.
type CheckerFunction = (value: unknown, schema: ValidationSchema, path: string, parent: object | null, context: Context) => true | ValidationError[]; | |
type CheckerFunction<T = unknown> = (value: T, schema: ValidationSchema, path: string, parent: object | null, context: Context) => true | ValidationError[]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The same case as in the previous conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Guess it can be resolved by that comment #122 (comment)
Maybe |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks to both of you!
Hello! I've improve some type definitions.
add
method).unknown
.min: 1
type
changed to message name,message
- string for custom messagecompile
,validate
methods fix: now it can beany
type - not only object.