fix: remove unnecessary pattern from ErrorString

This commit is contained in:
Chen Asraf
2022-11-11 00:15:35 +02:00
parent d19b931ff1
commit 726da34126
4 changed files with 10 additions and 16 deletions

View File

@@ -1,11 +1,17 @@
# v0.1.2
# Changelog
## v0.1.3
- fix: remove unnecessary `pattern` from `ErrorString`
## v0.1.2
- fix: documentation
# v0.1.1
## v0.1.1
- chore: code cleanups
# v0.1.0
## v0.1.0
- Initial release

View File

@@ -1,6 +1,6 @@
{
"name": "formplex-react",
"version": "0.1.2",
"version": "0.1.3",
"description": "Incredibly easy & flexible React form hooks",
"keywords": [
"react",

View File

@@ -218,15 +218,4 @@ export interface ErrorStrings {
* ```
*/
maxLength: string | ((length: number) => string)
/**
* Error message for when the field value does not match the given pattern.
*
* Can either be a string, or a function resolving to a string.
*
* Default:
* ```ts
* (p) => `Must match pattern ${p}`
* ```
*/
pattern: string | ((pattern: string | RegExp) => string)
}

View File

@@ -21,7 +21,6 @@ export function useForm<T>({
required: 'Required',
minLength: (n) => `Must be at least ${n} characters long`,
maxLength: (n) => `Must be no more than ${n} characters long`,
pattern: (p) => `Must match pattern ${p}`,
...errorMessages,
}
const [state, setState] = React.useState<Partial<T>>(initialState ?? {})