Skip to content

Commit 34c6108

Browse files
Alisher AripovAlisher Aripov
authored andcommitted
REFACTOR: fixed imports and changed README
1 parent 3deacf8 commit 34c6108

23 files changed

+879
-329
lines changed

README.md

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Fully typed form validation hooks for vue 3.
44
## Installation
55

66
```shell
7-
npm install vue3-validation
7+
npm i -S light-vue3-validation
88
```
99

1010
## Usage
@@ -125,20 +125,37 @@ reactive({
125125
</script>
126126
```
127127

128+
**If some filed in your object not need validation just write an empty array in rules `{ model: '', rules: [] }`**
129+
128130
### Also, you can use it without typescript, just don't write a types
129131
_Errors object in `useValidate` hooks will be soon_
130132

131133
## `useValidate` retrun
132134
Key | Value
133135
--- | ---
134-
model | Generic `<T>`
135-
isValid | `boolean`
136-
modelRules | An object with key of validation keyword `required, numeric etc...` and value of `boolean`
136+
`model` | Generic `<T>`
137+
`isValid` | `boolean`
138+
`modelRules` | An object with key of validation keyword `required, numeric etc...` and value of `boolean`
137139

138140
## `useValidateObject` return
139141
key | Value
140142
--- | ---
141143
Keys of your object | Keys wrapped by `useValidate` hook ` key: { model: ..., isValid: ..., modelRules: { ... } } `
142-
__isValid | `boolean`. Returns `true` if all `isValid` keys of your object items becomes `true`
143-
__clean | Returns `computed` **clean object** that you passed to hook with no wrapping by `useValidate` hook for each key
144+
`__isValid` | `boolean`. Returns `true` if all `isValid` keys of your object items becomes `true`
145+
`__clean` | Returns `computed` **clean object** that you passed to hook with no wrapping by `useValidate` hook for each key
146+
147+
## Rules
148+
Rule name | Properties
149+
--- | ---
150+
`alpha` | Accepts only alphabetic characters (a-z and A-Z). Numbers will be failed
151+
`alphaNum` | Accepts only alphabetic and numeric characters (a-z A-Z 0-9)
152+
`between` | Accepts an array of range that your number will be. Example `[10, 30]`. Your number will be valid if it in this range
153+
`email` | Accepts a string which is email
154+
`ipAddress` | Accepts a string like `###.###.###.###`
155+
`maxLength` | Accepts a string which length is less then max value you passed
156+
`minLength` | Accepts a string which length is more then min value you passed
157+
`maxValue` | Accepts a number which is less then max value you passed
158+
`minValue` | Accepts a number which is more then min value you passed
159+
`numeric` | Accepts only number 0-9
160+
`required` | Accepts anything and will be failed if model is empty
144161

coverage/clover.xml

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<coverage generated="1670082918688" clover="3.2.0">
3-
<project timestamp="1670082918688" name="All files">
4-
<metrics statements="147" coveredstatements="76" conditionals="12" coveredconditionals="12" methods="13" coveredmethods="11" elements="172" coveredelements="99" complexity="0" loc="147" ncloc="147" packages="1" files="1" classes="1"/>
5-
<file name="validators.ts" path="/Users/alisheraripov/Documents/work/libs/light-vue3-validation/dist/validators.ts">
6-
<metrics statements="147" coveredstatements="76" conditionals="12" coveredconditionals="12" methods="13" coveredmethods="11"/>
2+
<coverage generated="1670389796484" clover="3.2.0">
3+
<project timestamp="1670389796484" name="All files">
4+
<metrics statements="151" coveredstatements="78" conditionals="12" coveredconditionals="12" methods="13" coveredmethods="11" elements="176" coveredelements="101" complexity="0" loc="151" ncloc="151" packages="1" files="1" classes="1"/>
5+
<file name="index.ts" path="/Users/alisheraripov/Documents/work/libs/light-vue3-validation/dist/index.ts">
6+
<metrics statements="151" coveredstatements="78" conditionals="12" coveredconditionals="12" methods="13" coveredmethods="11"/>
77
<line num="1" count="1" type="stmt"/>
88
<line num="2" count="1" type="stmt"/>
99
<line num="3" count="1" type="stmt"/>
@@ -151,6 +151,10 @@
151151
<line num="145" count="0" type="stmt"/>
152152
<line num="146" count="0" type="stmt"/>
153153
<line num="147" count="0" type="stmt"/>
154+
<line num="148" count="0" type="stmt"/>
155+
<line num="149" count="0" type="stmt"/>
156+
<line num="150" count="1" type="stmt"/>
157+
<line num="151" count="1" type="stmt"/>
154158
</file>
155159
</project>
156160
</coverage>

coverage/coverage-final.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

coverage/lcov-report/index.html

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ <h1>All files</h1>
2323
<div class='clearfix'>
2424

2525
<div class='fl pad1y space-right2'>
26-
<span class="strong">51.7% </span>
26+
<span class="strong">51.65% </span>
2727
<span class="quiet">Statements</span>
28-
<span class='fraction'>76/147</span>
28+
<span class='fraction'>78/151</span>
2929
</div>
3030

3131

@@ -44,9 +44,9 @@ <h1>All files</h1>
4444

4545

4646
<div class='fl pad1y space-right2'>
47-
<span class="strong">51.7% </span>
47+
<span class="strong">51.65% </span>
4848
<span class="quiet">Lines</span>
49-
<span class='fraction'>76/147</span>
49+
<span class='fraction'>78/151</span>
5050
</div>
5151

5252

@@ -79,18 +79,18 @@ <h1>All files</h1>
7979
</tr>
8080
</thead>
8181
<tbody><tr>
82-
<td class="file medium" data-value="validators.ts"><a href="validators.ts.html">validators.ts</a></td>
83-
<td data-value="51.7" class="pic medium">
82+
<td class="file medium" data-value="index.ts"><a href="index.ts.html">index.ts</a></td>
83+
<td data-value="51.65" class="pic medium">
8484
<div class="chart"><div class="cover-fill" style="width: 51%"></div><div class="cover-empty" style="width: 49%"></div></div>
8585
</td>
86-
<td data-value="51.7" class="pct medium">51.7%</td>
87-
<td data-value="147" class="abs medium">76/147</td>
86+
<td data-value="51.65" class="pct medium">51.65%</td>
87+
<td data-value="151" class="abs medium">78/151</td>
8888
<td data-value="100" class="pct high">100%</td>
8989
<td data-value="12" class="abs high">12/12</td>
9090
<td data-value="84.61" class="pct high">84.61%</td>
9191
<td data-value="13" class="abs high">11/13</td>
92-
<td data-value="51.7" class="pct medium">51.7%</td>
93-
<td data-value="147" class="abs medium">76/147</td>
92+
<td data-value="51.65" class="pct medium">51.65%</td>
93+
<td data-value="151" class="abs medium">78/151</td>
9494
</tr>
9595

9696
</tbody>
@@ -101,7 +101,7 @@ <h1>All files</h1>
101101
<div class='footer quiet pad2 space-top1 center small'>
102102
Code coverage generated by
103103
<a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
104-
at 2022-12-03T15:55:18.679Z
104+
at 2022-12-07T05:09:56.475Z
105105
</div>
106106
<script src="prettify.js"></script>
107107
<script>

0 commit comments

Comments
 (0)