Skip to content

Commit

Permalink
some examples are added
Browse files Browse the repository at this point in the history
  • Loading branch information
thstamod committed Sep 26, 2020
1 parent 519733b commit 6d4e6d7
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 0 deletions.
26 changes: 26 additions & 0 deletions examples/optionsInheritFromConfig.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// @ts-nocheck
// @ts-ignore
import React, { useRef } from 'react'
import { useValidator } from 'light-react-validator'

const config: Config = {
globalMessages: { required: 'is required' }
}
const Component = () => {
const { track, submitForm, errors, formValidity } = useValidator(config)
return (
<div>
<input
id='free'
name='free'
aria-label='free'
type='text'
ref={(elem) =>
track(elem, {
rules: { required: true }
})
}
/>
</div>
)
}
24 changes: 24 additions & 0 deletions examples/simple.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// @ts-nocheck
// @ts-ignore
import React, { useRef } from 'react'
import { useValidator } from 'light-react-validator'

const Component = () => {
const { track, submitForm, errors } = useValidator()
return (
<div>
<input
id='email'
name='email'
aria-label='email'
type='text'
ref={(elem) =>
track(elem, {
rules: { required: true },
messages: { required: 'email is required' }
})
}
/>
</div>
)
}

0 comments on commit 6d4e6d7

Please sign in to comment.