Comparing version 1.0.0-pre-6 to 1.0.0-pre-7
@@ -36,3 +36,3 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
group: null, | ||
status: null, | ||
type: null, | ||
required: null, | ||
@@ -53,6 +53,6 @@ get value() { | ||
get hasError() { | ||
return this.status === 'error'; | ||
return this.type === 'error'; | ||
}, | ||
get hasWarning() { | ||
return this.status === 'warning'; | ||
return this.type === 'warning'; | ||
}, | ||
@@ -73,3 +73,3 @@ get path() { | ||
clear() { | ||
validatable.status = null; | ||
validatable.type = null; | ||
validatable.text = null; | ||
@@ -76,0 +76,0 @@ validatable.group = null; |
@@ -16,3 +16,3 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
group: null, | ||
status: null, | ||
type: null, | ||
get value() { | ||
@@ -34,6 +34,6 @@ return getter(); | ||
get hasError() { | ||
return this.status === 'error'; | ||
return this.type === 'error'; | ||
}, | ||
get hasWarning() { | ||
return this.status === 'warning'; | ||
return this.type === 'warning'; | ||
}, | ||
@@ -53,3 +53,3 @@ validate() { | ||
clear() { | ||
validatable.status = null; | ||
validatable.type = null; | ||
validatable.text = null; | ||
@@ -61,6 +61,6 @@ validatable.group = null; | ||
const message = messages === null || messages === void 0 ? void 0 : messages[this.path]; | ||
if (message && message.status !== 'success') { | ||
if (message && message.type !== 'success') { | ||
validatable.text = message.text; | ||
validatable.group = message.group; | ||
validatable.status = message.status; | ||
validatable.type = message.type; | ||
} | ||
@@ -70,3 +70,3 @@ else { | ||
validatable.group = undefined; | ||
validatable.status = undefined; | ||
validatable.type = undefined; | ||
} | ||
@@ -73,0 +73,0 @@ }, |
@@ -50,5 +50,5 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
const fieldResults = results.filter((r) => r).flatMap((r) => r.results); | ||
const warnings = fieldResults.filter((r) => r.status === 'warning'); | ||
const hasErrors = fieldResults.some((r) => r.status === 'error'); | ||
obj.status = hasErrors ? 'error' : warnings.length > 0 ? 'warning' : 'success'; | ||
const warnings = fieldResults.filter((r) => r.type === 'warning'); | ||
const hasErrors = fieldResults.some((r) => r.type === 'error'); | ||
obj.type = hasErrors ? 'error' : warnings.length > 0 ? 'warning' : 'success'; | ||
return { | ||
@@ -102,18 +102,18 @@ results: fieldResults, | ||
if (result) { | ||
field.status = result.status; | ||
field.type = result.type; | ||
field.text = result.text; | ||
field.group = result.group; | ||
const status = (_a = result.status) === null || _a === void 0 ? void 0 : _a.toLowerCase(); | ||
return status === 'success' | ||
const type = (_a = result.type) === null || _a === void 0 ? void 0 : _a.toLowerCase(); | ||
return type === 'success' | ||
? success() | ||
: { | ||
results: [result], | ||
hasErrors: status === 'error', | ||
hasWarnings: status === 'warning', | ||
warningHash: status === 'warning' ? result.text : null, | ||
success: status === 'success' || !status | ||
hasErrors: type === 'error', | ||
hasWarnings: type === 'warning', | ||
warningHash: type === 'warning' ? result.text : null, | ||
success: type === 'success' || !type | ||
}; | ||
} | ||
else { | ||
field.status = 'success'; | ||
field.type = 'success'; | ||
field.text = null; | ||
@@ -187,3 +187,3 @@ field.group = null; | ||
path: validatable.path, | ||
status: 'error', | ||
type: 'error', | ||
text: r, | ||
@@ -194,3 +194,3 @@ group: null | ||
} | ||
else if (r.status !== 'success') { | ||
else if (r.type !== 'success') { | ||
result = r; | ||
@@ -206,3 +206,3 @@ break; | ||
path: validatable.path, | ||
status: 'error', | ||
type: 'error', | ||
text: 'Validation failed.', | ||
@@ -213,3 +213,3 @@ group: null | ||
} | ||
return result && result.status !== 'success' ? result : null; | ||
return result && result.type !== 'success' ? result : null; | ||
}); | ||
@@ -216,0 +216,0 @@ } |
@@ -32,7 +32,7 @@ export type DryvValidateFunctionResult = DryvFieldValidationResult | string | null | undefined | Promise<DryvFieldValidationResult | string | null | undefined>; | ||
path?: string; | ||
status?: DryvValidationResultStatus; | ||
type?: DryvValidationResultType; | ||
text?: string | null; | ||
group?: string | null; | ||
} | ||
export type DryvValidationResultStatus = 'error' | 'warning' | 'success' | string; | ||
export type DryvValidationResultType = 'error' | 'warning' | 'success' | string; | ||
export type DryvProxy<TModel extends object> = TModel & { | ||
@@ -44,3 +44,3 @@ $dryv: DryvValidatable<TModel, DryvObject<TModel>>; | ||
results: { | ||
status: DryvValidationResultStatus; | ||
type: DryvValidationResultType; | ||
texts: string[]; | ||
@@ -56,3 +56,3 @@ }[]; | ||
groupShown?: boolean | null; | ||
status?: DryvValidationResultStatus | null; | ||
type?: DryvValidationResultType | null; | ||
value: TValue | undefined; | ||
@@ -71,3 +71,3 @@ parent: DryvValidatable | undefined; | ||
text?: string | null; | ||
status?: DryvValidationResultStatus | null; | ||
type?: DryvValidationResultType | null; | ||
} | ||
@@ -74,0 +74,0 @@ export type DryvObject<TModel extends object> = { |
{ | ||
"name": "dryvjs", | ||
"version": "1.0.0-pre-6", | ||
"version": "1.0.0-pre-7", | ||
"main": "dist/index.js", | ||
@@ -5,0 +5,0 @@ "types": "dist/index.d.ts", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
60104