@splitty-test/validation 0.1.0 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +3 -33
- package/dist/FieldValidation.vue.d.ts +54 -0
- package/dist/FieldValidatorClass.d.ts +22 -0
- package/dist/ValidatorClass.d.ts +24 -0
- package/{lib/index.ts → dist/index.d.ts} +1 -2
- package/dist/index.mjs +1994 -0
- package/dist/index.umd.js +1 -0
- package/dist/rules/index.d.ts +2 -0
- package/dist/rules/match.d.ts +1 -0
- package/package.json +15 -15
- package/vite.config.ts +9 -8
- package/.editorconfig +0 -8
- package/.vscode/extensions.json +0 -8
- package/lib/FieldValidation.vue +0 -96
- package/lib/FieldValidatorClass.ts +0 -96
- package/lib/ValidatorClass.ts +0 -106
- package/lib/rules/index.ts +0 -0
- package/lib/rules/match.ts +0 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Ronnie Garcia
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,39 +1,9 @@
|
|
|
1
1
|
# validation
|
|
2
2
|
|
|
3
|
-
This
|
|
3
|
+
This is a validation library for Vue 3 that is both simple but powerful. More documentation is coming soon.
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## Installation
|
|
6
6
|
|
|
7
|
-
[VSCode](https://code.visualstudio.com/) + [Volar](https://marketplace.visualstudio.com/items?itemName=Vue.volar) (and disable Vetur).
|
|
8
|
-
|
|
9
|
-
## Type Support for `.vue` Imports in TS
|
|
10
|
-
|
|
11
|
-
TypeScript cannot handle type information for `.vue` imports by default, so we replace the `tsc` CLI with `vue-tsc` for type checking. In editors, we need [Volar](https://marketplace.visualstudio.com/items?itemName=Vue.volar) to make the TypeScript language service aware of `.vue` types.
|
|
12
|
-
|
|
13
|
-
## Customize configuration
|
|
14
|
-
|
|
15
|
-
See [Vite Configuration Reference](https://vite.dev/config/).
|
|
16
|
-
|
|
17
|
-
## Project Setup
|
|
18
|
-
|
|
19
|
-
```sh
|
|
20
|
-
npm install
|
|
21
|
-
```
|
|
22
|
-
|
|
23
|
-
### Compile and Hot-Reload for Development
|
|
24
|
-
|
|
25
|
-
```sh
|
|
26
|
-
npm run dev
|
|
27
7
|
```
|
|
28
|
-
|
|
29
|
-
### Type-Check, Compile and Minify for Production
|
|
30
|
-
|
|
31
|
-
```sh
|
|
32
|
-
npm run build
|
|
33
|
-
```
|
|
34
|
-
|
|
35
|
-
### Lint with [ESLint](https://eslint.org/)
|
|
36
|
-
|
|
37
|
-
```sh
|
|
38
|
-
npm run lint
|
|
8
|
+
npm install @splitty-test/validation
|
|
39
9
|
```
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { PropType } from 'vue';
|
|
2
|
+
import { Validator } from './ValidatorClass';
|
|
3
|
+
import { ValidationRule } from './FieldValidatorClass';
|
|
4
|
+
declare const _default: import('vue').DefineComponent<import('vue').ExtractPropTypes<{
|
|
5
|
+
name: {
|
|
6
|
+
type: StringConstructor;
|
|
7
|
+
required: true;
|
|
8
|
+
};
|
|
9
|
+
hideError: BooleanConstructor;
|
|
10
|
+
modelValue: {
|
|
11
|
+
type: null;
|
|
12
|
+
};
|
|
13
|
+
modelModifiers: {
|
|
14
|
+
default: () => {};
|
|
15
|
+
};
|
|
16
|
+
rules: {
|
|
17
|
+
type: PropType<ValidationRule[]>;
|
|
18
|
+
default(): never[];
|
|
19
|
+
};
|
|
20
|
+
validator: {
|
|
21
|
+
type: typeof Validator;
|
|
22
|
+
required: true;
|
|
23
|
+
};
|
|
24
|
+
}>, {}, {
|
|
25
|
+
form_fields: HTMLElement[];
|
|
26
|
+
}, {
|
|
27
|
+
field(): import('./FieldValidatorClass').FieldValidator;
|
|
28
|
+
error(): string | null | undefined;
|
|
29
|
+
}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<{
|
|
30
|
+
name: {
|
|
31
|
+
type: StringConstructor;
|
|
32
|
+
required: true;
|
|
33
|
+
};
|
|
34
|
+
hideError: BooleanConstructor;
|
|
35
|
+
modelValue: {
|
|
36
|
+
type: null;
|
|
37
|
+
};
|
|
38
|
+
modelModifiers: {
|
|
39
|
+
default: () => {};
|
|
40
|
+
};
|
|
41
|
+
rules: {
|
|
42
|
+
type: PropType<ValidationRule[]>;
|
|
43
|
+
default(): never[];
|
|
44
|
+
};
|
|
45
|
+
validator: {
|
|
46
|
+
type: typeof Validator;
|
|
47
|
+
required: true;
|
|
48
|
+
};
|
|
49
|
+
}>> & Readonly<{}>, {
|
|
50
|
+
hideError: boolean;
|
|
51
|
+
modelModifiers: {};
|
|
52
|
+
rules: ValidationRule[];
|
|
53
|
+
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
|
|
54
|
+
export default _default;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Validator } from './ValidatorClass';
|
|
2
|
+
export interface FieldValidatorConfig {
|
|
3
|
+
value: any;
|
|
4
|
+
rules: ValidationRule[];
|
|
5
|
+
group?: string;
|
|
6
|
+
}
|
|
7
|
+
export type ValidationRule = (value: any, ...args: any) => Promise<string | null> | (string | null);
|
|
8
|
+
export declare class FieldValidator {
|
|
9
|
+
controls: HTMLElement[];
|
|
10
|
+
dirty: boolean;
|
|
11
|
+
errors: string[];
|
|
12
|
+
group?: string;
|
|
13
|
+
rules: ValidationRule[];
|
|
14
|
+
touched: boolean;
|
|
15
|
+
validated: boolean;
|
|
16
|
+
validator: Validator;
|
|
17
|
+
value: any;
|
|
18
|
+
constructor(config: FieldValidatorConfig, validator: Validator);
|
|
19
|
+
get isValid(): boolean;
|
|
20
|
+
reset(): void;
|
|
21
|
+
validate(): Promise<boolean>;
|
|
22
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { FieldValidator, FieldValidatorConfig } from './FieldValidatorClass';
|
|
2
|
+
export interface ValidatorConfig {
|
|
3
|
+
fields?: Record<string, FieldValidatorConfig>;
|
|
4
|
+
}
|
|
5
|
+
export interface ValidationGroup {
|
|
6
|
+
dirty: boolean;
|
|
7
|
+
fields: Record<string, FieldValidator>;
|
|
8
|
+
touched: boolean;
|
|
9
|
+
validated: boolean;
|
|
10
|
+
}
|
|
11
|
+
export declare class Validator {
|
|
12
|
+
dirty: boolean;
|
|
13
|
+
errors: string[];
|
|
14
|
+
fields: Record<string, FieldValidator>;
|
|
15
|
+
groups: Record<string, ValidationGroup>;
|
|
16
|
+
touched: boolean;
|
|
17
|
+
validated: boolean;
|
|
18
|
+
constructor(config?: ValidatorConfig);
|
|
19
|
+
isValid(group_name?: string): boolean;
|
|
20
|
+
reset(group_name?: string): void;
|
|
21
|
+
addField(field_name: string, field_config: FieldValidatorConfig): void;
|
|
22
|
+
removeField(field_name: string): void;
|
|
23
|
+
validate(group_name?: string): Promise<void>;
|
|
24
|
+
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { Validator } from './ValidatorClass';
|
|
2
2
|
import { FieldValidator } from './FieldValidatorClass';
|
|
3
|
-
import FieldValidation from './FieldValidation.vue';
|
|
3
|
+
import { default as FieldValidation } from './FieldValidation.vue';
|
|
4
4
|
import * as rules from './rules';
|
|
5
|
-
|
|
6
5
|
export { Validator, FieldValidator, FieldValidation, rules };
|