@vaadin/hilla-lit-form 25.3.0 → 25.4.0-alpha1
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/Validators.d.ts +1 -1
- package/Validators.js +3 -3
- package/Validators.js.map +1 -1
- package/index.js +1 -1
- package/index.js.map +1 -1
- package/package.json +3 -3
package/Validators.d.ts
CHANGED
|
@@ -125,7 +125,7 @@ export declare class Size extends AbstractValidator<string> {
|
|
|
125
125
|
min: number;
|
|
126
126
|
max: number;
|
|
127
127
|
constructor(attrs?: SizeAttributes);
|
|
128
|
-
validate(value: string): boolean;
|
|
128
|
+
validate(value: string | null | undefined): boolean;
|
|
129
129
|
readonly name = "Size";
|
|
130
130
|
}
|
|
131
131
|
export declare class Digits<T> extends AbstractValidator<T> {
|
package/Validators.js
CHANGED
|
@@ -376,8 +376,8 @@ export class Size extends AbstractValidator {
|
|
|
376
376
|
}
|
|
377
377
|
}
|
|
378
378
|
validate(value) {
|
|
379
|
-
if (
|
|
380
|
-
return
|
|
379
|
+
if (value == null || value.length === 0) {
|
|
380
|
+
return this.min <= 0;
|
|
381
381
|
}
|
|
382
382
|
return isLength(value, { min: this.min, max: this.max });
|
|
383
383
|
}
|
|
@@ -475,7 +475,7 @@ export class Pattern extends AbstractValidator {
|
|
|
475
475
|
this.regexp = _regexp(attrs);
|
|
476
476
|
}
|
|
477
477
|
validate(value) {
|
|
478
|
-
return matches(value, this.regexp);
|
|
478
|
+
return value == null || matches(value, this.regexp);
|
|
479
479
|
}
|
|
480
480
|
}
|
|
481
481
|
export class ValidityStateValidator extends AbstractValidator {
|
package/Validators.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Validators.js","sourceRoot":"","sources":["src/Validators.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,6BAA6B,CAAC;AAClD,OAAO,QAAQ,MAAM,8BAA8B,CAAC;AACpD,OAAO,SAAS,MAAM,+BAA+B,CA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,CAAC;AACtB,CAAC;AAED,MAAM,OAAO,OAAQ,SAAQ,iBAAyB;IAGpD,YAAY,KAA0C;QACpD,KAAK,CAAC;YACJ,OAAO,EAAE,gDAAgD,OAAO,CAAC,KAAK,CAAC,CAAC,QAAQ,EAAE,EAAE;YACpF,GAAG,sBAAsB,CAAC,KAAK,CAAC;SACjC,CAAC,CAAC;QANL;;;;;WAAe;QAcN;;;;mBAAO,SAAS;WAAC;QAPxB,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC;IAC/B,CAAC;IAEQ,QAAQ,CAAC,KAAU;QAC1B,OAAO,OAAO,CAAC,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;IACrC,CAAC;CAGF;AAMD,MAAM,OAAO,sBAA0B,SAAQ,iBAAoB;IAIjE;QACE,KAAK,EAAE,CAAC;QAJD;;;;mBAAU,EAAE;WAAC;QAWb;;;;mBAAO,wBAAwB;WAAC;IANzC,CAAC;IAEQ,QAAQ;QACf,OAAO,KAAK,CAAC;IACf,CAAC;CAGF","sourcesContent":["import isAfter from 'validator/es/lib/isAfter.js';\nimport isBefore from 'validator/es/lib/isBefore.js';\nimport isBoolean from 'validator/es/lib/isBoolean.js';\nimport isDecimal from 'validator/es/lib/isDecimal.js';\nimport isEmail from 'validator/es/lib/isEmail.js';\nimport isFloat from 'validator/es/lib/isFloat.js';\nimport isLength from 'validator/es/lib/isLength.js';\nimport matches from 'validator/es/lib/matches.js';\nimport toFloat from 'validator/es/lib/toFloat.js';\nimport type { Validator } from './Validation.js';\n\ninterface ValidatorAttributes {\n message?: string;\n}\ninterface ValueNumberAttributes extends ValidatorAttributes {\n value: number | string;\n}\ninterface DigitAttributes extends ValidatorAttributes {\n integer: number;\n fraction: number;\n}\ninterface SizeAttributes extends ValidatorAttributes {\n min?: number;\n max?: number;\n}\ninterface PatternAttributes extends ValidatorAttributes {\n regexp: RegExp | string;\n}\ninterface DecimalAttributes extends ValueNumberAttributes {\n inclusive?: boolean;\n}\n\nabstract class AbstractValidator<T> implements Validator<T> {\n message = 'invalid';\n\n impliesRequired = false;\n\n constructor(attrs?: ValidatorAttributes) {\n if (attrs?.message) {\n this.message = attrs.message;\n }\n }\n\n abstract validate(value: T): Promise<boolean> | boolean;\n abstract get name(): string;\n}\n\nexport class Required<T> extends AbstractValidator<T> {\n override impliesRequired = true;\n\n override validate(value: T): boolean {\n if (typeof value === 'string' || Array.isArray(value)) {\n return value.length > 0;\n }\n if (typeof value === 'number') {\n return Number.isFinite(value);\n }\n return value !== undefined;\n }\n\n readonly name: string = 'Required';\n}\n\nfunction _asValidatorAttributes(attrs: PatternAttributes | RegExp | ValueNumberAttributes | number | string) {\n return typeof attrs === 'object' ? attrs : {};\n}\n\nfunction _value(attrs: ValueNumberAttributes | number | string) {\n return typeof attrs === 'object' ? attrs.value : attrs;\n}\n\nabstract class NumberValidator<T> extends AbstractValidator<T> {\n override validate(value: T) {\n const num = Number(value);\n return !isNaN(num) && isFinite(num);\n }\n}\n\nexport class IsNumber extends NumberValidator<number | null | undefined> {\n optional: boolean;\n\n constructor(optional: boolean, attrs?: ValidatorAttributes) {\n super({ message: 'must be a number', ...attrs });\n this.optional = optional;\n }\n\n override validate(value: number | null | undefined): boolean {\n return (this.optional && value == null) || super.validate(value);\n }\n\n readonly name = 'IsNumber';\n}\n\nabstract class ValueNumberValidator<T> extends NumberValidator<T> {\n value: number;\n\n protected constructor(attrs: ValueNumberAttributes | number | string) {\n super(_asValidatorAttributes(attrs));\n const val = _value(attrs);\n this.value = typeof val === 'string' ? parseFloat(val) : val;\n }\n}\n\n// JSR380 equivalent (https://beanvalidation.org/2.0/spec/#builtinconstraints)\nexport class Email extends AbstractValidator<string> {\n constructor(attrs?: ValidatorAttributes) {\n super({ message: 'must be a well-formed email address', ...attrs });\n }\n\n override validate(value: string | null | undefined): boolean {\n return !value || isEmail(value);\n }\n\n readonly name = 'Email';\n}\n\nexport class Null extends AbstractValidator<any> {\n constructor(attrs?: ValidatorAttributes) {\n super({ message: 'must be null', ...attrs });\n }\n\n override validate(value: any): boolean {\n return value == null;\n }\n\n readonly name = 'Null';\n}\n\nexport class NotNull<T> extends Required<T> {\n constructor(attrs?: ValidatorAttributes) {\n super({ message: 'must not be null', ...attrs });\n }\n\n override validate(value: T): value is NonNullable<T> {\n return !new Null().validate(value);\n }\n\n override readonly name = 'NotNull';\n}\n\nexport class NotEmpty<T> extends Required<T> {\n constructor(attrs?: ValidatorAttributes) {\n super({ message: 'must not be empty', ...attrs });\n }\n\n override validate(value: T): boolean {\n return (\n super.validate(value) && new NotNull<T>().validate(value) && ((value as { length?: number }).length ?? 0) > 0\n );\n }\n\n override readonly name = 'NotEmpty';\n}\n\nexport class NotBlank<T> extends Required<T> {\n constructor(attrs?: ValidatorAttributes) {\n super({ message: 'must not be blank', ...attrs });\n }\n\n override validate(value: T): boolean {\n return super.validate(value) && new NotNull<T>().validate(value) && String(value).trim().length > 0;\n }\n\n override readonly name = 'NotBlank';\n}\n\nexport class AssertTrue<T> extends AbstractValidator<T> {\n constructor(attrs?: ValidatorAttributes) {\n super({ message: 'must be true', ...attrs });\n }\n\n override validate(value: T): boolean {\n return isBoolean(String(value)) && String(value) === 'true';\n }\n\n readonly name = 'AssertTrue';\n}\n\nexport class AssertFalse<T> extends AbstractValidator<T> {\n constructor(attrs?: ValidatorAttributes) {\n super({ message: 'must be false', ...attrs });\n }\n\n override validate(value: T): boolean {\n return !new AssertTrue<T>().validate(value);\n }\n\n readonly name = 'AssertFalse';\n}\n\nfunction _asValueNumberAttributes(attrs: ValueNumberAttributes | number | string) {\n return typeof attrs === 'object' ? attrs : { value: attrs };\n}\n\nexport class Min<T> extends ValueNumberValidator<T> {\n constructor(attrs: ValueNumberAttributes | number | string) {\n super({\n message: `must be greater than or equal to ${_value(attrs)}`,\n ..._asValueNumberAttributes(attrs),\n });\n }\n\n override validate(value: T): boolean {\n return super.validate(value) && isFloat(String(value), { min: this.value });\n }\n\n readonly name = 'Min';\n}\n\nexport class Max<T> extends ValueNumberValidator<T> {\n constructor(attrs: ValueNumberAttributes | number | string) {\n super({\n message: `must be less than or equal to ${_value(attrs)}`,\n ..._asValueNumberAttributes(attrs),\n });\n }\n\n override validate(value: T): boolean {\n return super.validate(value) && isFloat(String(value), { max: this.value });\n }\n\n readonly name = 'Max';\n}\n\nfunction _inclusive(attrs: DecimalAttributes | number | string) {\n return typeof attrs !== 'object' || attrs.inclusive !== false;\n}\n\nexport class DecimalMin<T> extends ValueNumberValidator<T> {\n inclusive: boolean;\n\n constructor(attrs: DecimalAttributes | number | string) {\n super({\n message: `must be greater than ${_inclusive(attrs) ? 'or equal to ' : ''}${_value(attrs)}`,\n ..._asValueNumberAttributes(attrs),\n });\n this.inclusive = _inclusive(attrs);\n }\n\n override validate(value: T): boolean {\n return super.validate(value) && isFloat(String(value), { [this.inclusive ? 'min' : 'gt']: this.value });\n }\n\n readonly name = 'DecimalMin';\n}\n\nexport class DecimalMax<T> extends ValueNumberValidator<T> {\n inclusive: boolean;\n\n constructor(attrs: DecimalAttributes | number | string) {\n super({\n message: `must be less than ${_inclusive(attrs) ? 'or equal to ' : ''}${_value(attrs)}`,\n ..._asValueNumberAttributes(attrs),\n });\n this.inclusive = _inclusive(attrs);\n }\n\n override validate(value: T): boolean {\n return super.validate(value) && isFloat(String(value), { [this.inclusive ? 'max' : 'lt']: this.value });\n }\n\n readonly name = 'DecimalMax';\n}\n\nexport class Negative<T> extends AbstractValidator<T> {\n constructor(attrs?: ValidatorAttributes) {\n super({ message: 'must be less than 0', ...attrs });\n }\n\n override validate(value: T): boolean {\n const fv = toFloat(String(value));\n return isNaN(fv) || fv < 0;\n }\n\n readonly name = 'Negative';\n}\n\nexport class NegativeOrZero<T> extends AbstractValidator<T> {\n constructor(attrs?: ValidatorAttributes) {\n super({ message: 'must be less than or equal to 0', ...attrs });\n }\n\n override validate(value: T): boolean {\n return (toFloat(String(value)) || 0) <= 0;\n }\n\n readonly name = 'NegativeOrZero';\n}\n\nexport class Positive<T> extends AbstractValidator<T> {\n constructor(attrs?: ValidatorAttributes) {\n super({ message: 'must be greater than 0', ...attrs });\n }\n\n override validate(value: T): boolean {\n const fv = toFloat(String(value));\n return isNaN(fv) || fv > 0;\n }\n\n readonly name = 'Positive';\n}\n\nexport class PositiveOrZero<T> extends AbstractValidator<T> {\n constructor(attrs?: ValidatorAttributes) {\n super({ message: 'must be greater than or equal to 0', ...attrs });\n }\n\n override validate(value: T): boolean {\n return (toFloat(String(value)) || 0) >= 0;\n }\n\n readonly name = 'PositiveOrZero';\n}\n\nfunction _min(attrs: SizeAttributes) {\n return attrs.min ?? 0;\n}\n\nfunction _max(attrs: SizeAttributes) {\n return attrs.max ?? Number.MAX_SAFE_INTEGER;\n}\n\nexport class Size extends AbstractValidator<string> {\n min: number;\n max: number;\n\n constructor(attrs: SizeAttributes = {}) {\n super({ message: `size must be between ${_min(attrs)} and ${_max(attrs)}`, ...attrs });\n this.min = _min(attrs);\n this.max = _max(attrs);\n if (this.min > 0) {\n this.impliesRequired = true;\n }\n }\n\n override validate(value: string): boolean {\n if (this.min && this.min > 0 && !new Required().validate(value)) {\n return false;\n }\n // eslint-disable-next-line sort-keys\n return isLength(value, { min: this.min, max: this.max });\n }\n\n readonly name = 'Size';\n}\n\nexport class Digits<T> extends AbstractValidator<T> {\n integer: number;\n fraction: number;\n\n constructor(attrs: DigitAttributes) {\n super({\n message: `numeric value out of bounds (<${attrs.integer} digits>.<${attrs.fraction} digits> expected)`,\n ...attrs,\n });\n this.integer = attrs.integer;\n this.fraction = attrs.fraction;\n }\n\n override validate(value: T): boolean {\n return (\n String(Math.floor(Math.abs(toFloat(String(value))))).length <= this.integer &&\n // eslint-disable-next-line camelcase\n isDecimal(String(value), { decimal_digits: `0,${this.fraction}` })\n );\n }\n\n readonly name = 'Digits';\n}\n\nexport class Past<T> extends AbstractValidator<T> {\n constructor(attrs?: ValidatorAttributes) {\n super({ message: 'must be a past date', ...attrs });\n }\n\n override validate(value: T): boolean {\n return isBefore(String(value));\n }\n\n readonly name = 'Past';\n}\n\n/*\n @PastOrPresent has no client-side implementation yet.\n It would consider any input valid and let the server-side to do validation.\n (It's not trivial to ensure the same granularity of _present_ as on the server-side:\n year / month / day / minute).\n*/\n// export class PastOrPresent extends AbstractValidator<any> {\n// constructor(attrs?: ValidatorAttributes) {\n// super({ message: 'must be a date in the past or in the present', ...attrs });\n// }\n// validate() {\n// return true;\n// }\n// }\n\nexport class Future<T> extends AbstractValidator<T> {\n constructor(attrs?: ValidatorAttributes) {\n super({ message: 'must be a future date', ...attrs });\n }\n\n override validate(value: T): boolean {\n return isAfter(String(value));\n }\n\n readonly name = 'Future';\n}\n\n/*\n @FutureOrPresent has no client-side implementation yet.\n It would consider any input valid and let the server-side to do validation.\n (It's not trivial to ensure the same granularity of _present_ as on the server-side:\n year / month / day / minute).\n*/\n// export class FutureOrPresent extends AbstractValidator<any> {\n// constructor(attrs?: ValidatorAttributes) {\n// super({ message: 'must be a date in the present or in the future', ...attrs });\n// }\n// validate = () => true;\n// }\n\nfunction _regexp(attrs: PatternAttributes | RegExp | string) {\n if (typeof attrs === 'string') {\n return new RegExp(attrs, 'u');\n }\n\n if (attrs instanceof RegExp) {\n return attrs;\n }\n\n if (typeof attrs.regexp === 'string') {\n return new RegExp(attrs.regexp, 'u');\n }\n\n return attrs.regexp;\n}\n\nexport class Pattern extends AbstractValidator<string> {\n regexp: RegExp;\n\n constructor(attrs: PatternAttributes | RegExp | string) {\n super({\n message: `must match the following regular expression: ${_regexp(attrs).toString()}`,\n ..._asValidatorAttributes(attrs),\n });\n this.regexp = _regexp(attrs);\n }\n\n override validate(value: any): boolean {\n return matches(value, this.regexp);\n }\n\n readonly name = 'Pattern';\n}\n\n/**\n * Validator that reports an error when the bound HTML element validation\n * returns false from `element.checkValidity()` and `element.validity.valid`.\n */\nexport class ValidityStateValidator<T> extends AbstractValidator<T> {\n override message = '';\n\n // eslint-disable-next-line no-useless-constructor,@typescript-eslint/no-useless-constructor\n constructor() {\n super();\n }\n\n override validate(): boolean {\n return false;\n }\n\n readonly name = 'ValidityStateValidator';\n}\n"]}
|
|
1
|
+
{"version":3,"file":"Validators.js","sourceRoot":"","sources":["src/Validators.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,6BAA6B,CAAC;AAClD,OAAO,QAAQ,MAAM,8BAA8B,CAAC;AACpD,OAAO,SAAS,MAAM,+BAA+B,CAAC;AACtD,OAAO,SAAS,MAAM,+BAA+B,CAAC;AACtD,OAAO,OAAO,MAAM,6BAA6B,CAAC;AAClD,OAAO,OAAO,MAAM,6BAA6B,CAAC;AAClD,OAAO,QAAQ,MAAM,8BAA8B,CAAC;AACpD,OAAO,OAAO,MAAM,6BAA6B,CAAC;AAClD,OAAO,OAAO,MAAM,6BAA6B,CAAC;AAwBlD,MAAe,iBAAiB;IAK9B,YAAY,KAA2B;QAJvC;;;;mBAAU,SAAS;WAAC;QAEpB;;;;mBAAkB,KAAK;WAAC;QAGtB,IAAI,KAAK,EAAE,OAAO,EAAE,CAAC;YACnB,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC;QAC/B,CAAC;IACH,CAAC;CAIF;AAED,MAAM,OAAO,QAAY,SAAQ,iBAAoB;IAArD;;QACW;;;;mBAAkB,IAAI;WAAC;QAYvB;;;;mBAAe,UAAU;WAAC;IACrC,CAAC;IAXU,QAAQ,CAAC,KAAQ;QACxB,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;YACtD,OAAO,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC;QAC1B,CAAC;QACD,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;YAC9B,OAAO,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;QAChC,CAAC;QACD,OAAO,KAAK,KAAK,SAAS,CAAC;IAC7B,CAAC;CAGF;AAED,SAAS,sBAAsB,CAAC,KAA2E;IACzG,OAAO,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AAE,CAAC;QAC5B,OAAO,KAAK,CAAC;IACf,CAAC;IAED,IAAI,OAAO,KAAK,CAAC,MAAM,KAAK,QAAQ,EAAE,CAAC;QACrC,OAAO,IAAI,MAAM,CAAC,KAAK,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IACvC,CAAC;IAED,OAAO,KAAK,CAAC,MAAM,CAAC;AACtB,CAAC;AAED,MAAM,OAAO,OAAQ,SAAQ,iBAAyB;IAGpD,YAAY,KAA0C;QACpD,KAAK,CAAC;YACJ,OAAO,EAAE,gDAAgD,OAAO,CAAC,KAAK,CAAC,CAAC,QAAQ,EAAE,EAAE;YACpF,GAAG,sBAAsB,CAAC,KAAK,CAAC;SACjC,CAAC,CAAC;QANL;;;;;WAAe;QAeN;;;;mBAAO,SAAS;WAAC;QARxB,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC;IAC/B,CAAC;IAEQ,QAAQ,CAAC,KAAU;QAE1B,OAAO,KAAK,IAAI,IAAI,IAAI,OAAO,CAAC,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;IACtD,CAAC;CAGF;AAMD,MAAM,OAAO,sBAA0B,SAAQ,iBAAoB;IAIjE;QACE,KAAK,EAAE,CAAC;QAJD;;;;mBAAU,EAAE;WAAC;QAWb;;;;mBAAO,wBAAwB;WAAC;IANzC,CAAC;IAEQ,QAAQ;QACf,OAAO,KAAK,CAAC;IACf,CAAC;CAGF","sourcesContent":["import isAfter from 'validator/es/lib/isAfter.js';\nimport isBefore from 'validator/es/lib/isBefore.js';\nimport isBoolean from 'validator/es/lib/isBoolean.js';\nimport isDecimal from 'validator/es/lib/isDecimal.js';\nimport isEmail from 'validator/es/lib/isEmail.js';\nimport isFloat from 'validator/es/lib/isFloat.js';\nimport isLength from 'validator/es/lib/isLength.js';\nimport matches from 'validator/es/lib/matches.js';\nimport toFloat from 'validator/es/lib/toFloat.js';\nimport type { Validator } from './Validation.js';\n\ninterface ValidatorAttributes {\n message?: string;\n}\ninterface ValueNumberAttributes extends ValidatorAttributes {\n value: number | string;\n}\ninterface DigitAttributes extends ValidatorAttributes {\n integer: number;\n fraction: number;\n}\ninterface SizeAttributes extends ValidatorAttributes {\n min?: number;\n max?: number;\n}\ninterface PatternAttributes extends ValidatorAttributes {\n regexp: RegExp | string;\n}\ninterface DecimalAttributes extends ValueNumberAttributes {\n inclusive?: boolean;\n}\n\nabstract class AbstractValidator<T> implements Validator<T> {\n message = 'invalid';\n\n impliesRequired = false;\n\n constructor(attrs?: ValidatorAttributes) {\n if (attrs?.message) {\n this.message = attrs.message;\n }\n }\n\n abstract validate(value: T): Promise<boolean> | boolean;\n abstract get name(): string;\n}\n\nexport class Required<T> extends AbstractValidator<T> {\n override impliesRequired = true;\n\n override validate(value: T): boolean {\n if (typeof value === 'string' || Array.isArray(value)) {\n return value.length > 0;\n }\n if (typeof value === 'number') {\n return Number.isFinite(value);\n }\n return value !== undefined;\n }\n\n readonly name: string = 'Required';\n}\n\nfunction _asValidatorAttributes(attrs: PatternAttributes | RegExp | ValueNumberAttributes | number | string) {\n return typeof attrs === 'object' ? attrs : {};\n}\n\nfunction _value(attrs: ValueNumberAttributes | number | string) {\n return typeof attrs === 'object' ? attrs.value : attrs;\n}\n\nabstract class NumberValidator<T> extends AbstractValidator<T> {\n override validate(value: T) {\n const num = Number(value);\n return !isNaN(num) && isFinite(num);\n }\n}\n\nexport class IsNumber extends NumberValidator<number | null | undefined> {\n optional: boolean;\n\n constructor(optional: boolean, attrs?: ValidatorAttributes) {\n super({ message: 'must be a number', ...attrs });\n this.optional = optional;\n }\n\n override validate(value: number | null | undefined): boolean {\n return (this.optional && value == null) || super.validate(value);\n }\n\n readonly name = 'IsNumber';\n}\n\nabstract class ValueNumberValidator<T> extends NumberValidator<T> {\n value: number;\n\n protected constructor(attrs: ValueNumberAttributes | number | string) {\n super(_asValidatorAttributes(attrs));\n const val = _value(attrs);\n this.value = typeof val === 'string' ? parseFloat(val) : val;\n }\n}\n\n// JSR380 equivalent (https://beanvalidation.org/2.0/spec/#builtinconstraints)\nexport class Email extends AbstractValidator<string> {\n constructor(attrs?: ValidatorAttributes) {\n super({ message: 'must be a well-formed email address', ...attrs });\n }\n\n override validate(value: string | null | undefined): boolean {\n return !value || isEmail(value);\n }\n\n readonly name = 'Email';\n}\n\nexport class Null extends AbstractValidator<any> {\n constructor(attrs?: ValidatorAttributes) {\n super({ message: 'must be null', ...attrs });\n }\n\n override validate(value: any): boolean {\n return value == null;\n }\n\n readonly name = 'Null';\n}\n\nexport class NotNull<T> extends Required<T> {\n constructor(attrs?: ValidatorAttributes) {\n super({ message: 'must not be null', ...attrs });\n }\n\n override validate(value: T): value is NonNullable<T> {\n return !new Null().validate(value);\n }\n\n override readonly name = 'NotNull';\n}\n\nexport class NotEmpty<T> extends Required<T> {\n constructor(attrs?: ValidatorAttributes) {\n super({ message: 'must not be empty', ...attrs });\n }\n\n override validate(value: T): boolean {\n return (\n super.validate(value) && new NotNull<T>().validate(value) && ((value as { length?: number }).length ?? 0) > 0\n );\n }\n\n override readonly name = 'NotEmpty';\n}\n\nexport class NotBlank<T> extends Required<T> {\n constructor(attrs?: ValidatorAttributes) {\n super({ message: 'must not be blank', ...attrs });\n }\n\n override validate(value: T): boolean {\n return super.validate(value) && new NotNull<T>().validate(value) && String(value).trim().length > 0;\n }\n\n override readonly name = 'NotBlank';\n}\n\nexport class AssertTrue<T> extends AbstractValidator<T> {\n constructor(attrs?: ValidatorAttributes) {\n super({ message: 'must be true', ...attrs });\n }\n\n override validate(value: T): boolean {\n return isBoolean(String(value)) && String(value) === 'true';\n }\n\n readonly name = 'AssertTrue';\n}\n\nexport class AssertFalse<T> extends AbstractValidator<T> {\n constructor(attrs?: ValidatorAttributes) {\n super({ message: 'must be false', ...attrs });\n }\n\n override validate(value: T): boolean {\n return !new AssertTrue<T>().validate(value);\n }\n\n readonly name = 'AssertFalse';\n}\n\nfunction _asValueNumberAttributes(attrs: ValueNumberAttributes | number | string) {\n return typeof attrs === 'object' ? attrs : { value: attrs };\n}\n\nexport class Min<T> extends ValueNumberValidator<T> {\n constructor(attrs: ValueNumberAttributes | number | string) {\n super({\n message: `must be greater than or equal to ${_value(attrs)}`,\n ..._asValueNumberAttributes(attrs),\n });\n }\n\n override validate(value: T): boolean {\n return super.validate(value) && isFloat(String(value), { min: this.value });\n }\n\n readonly name = 'Min';\n}\n\nexport class Max<T> extends ValueNumberValidator<T> {\n constructor(attrs: ValueNumberAttributes | number | string) {\n super({\n message: `must be less than or equal to ${_value(attrs)}`,\n ..._asValueNumberAttributes(attrs),\n });\n }\n\n override validate(value: T): boolean {\n return super.validate(value) && isFloat(String(value), { max: this.value });\n }\n\n readonly name = 'Max';\n}\n\nfunction _inclusive(attrs: DecimalAttributes | number | string) {\n return typeof attrs !== 'object' || attrs.inclusive !== false;\n}\n\nexport class DecimalMin<T> extends ValueNumberValidator<T> {\n inclusive: boolean;\n\n constructor(attrs: DecimalAttributes | number | string) {\n super({\n message: `must be greater than ${_inclusive(attrs) ? 'or equal to ' : ''}${_value(attrs)}`,\n ..._asValueNumberAttributes(attrs),\n });\n this.inclusive = _inclusive(attrs);\n }\n\n override validate(value: T): boolean {\n return super.validate(value) && isFloat(String(value), { [this.inclusive ? 'min' : 'gt']: this.value });\n }\n\n readonly name = 'DecimalMin';\n}\n\nexport class DecimalMax<T> extends ValueNumberValidator<T> {\n inclusive: boolean;\n\n constructor(attrs: DecimalAttributes | number | string) {\n super({\n message: `must be less than ${_inclusive(attrs) ? 'or equal to ' : ''}${_value(attrs)}`,\n ..._asValueNumberAttributes(attrs),\n });\n this.inclusive = _inclusive(attrs);\n }\n\n override validate(value: T): boolean {\n return super.validate(value) && isFloat(String(value), { [this.inclusive ? 'max' : 'lt']: this.value });\n }\n\n readonly name = 'DecimalMax';\n}\n\nexport class Negative<T> extends AbstractValidator<T> {\n constructor(attrs?: ValidatorAttributes) {\n super({ message: 'must be less than 0', ...attrs });\n }\n\n override validate(value: T): boolean {\n const fv = toFloat(String(value));\n return isNaN(fv) || fv < 0;\n }\n\n readonly name = 'Negative';\n}\n\nexport class NegativeOrZero<T> extends AbstractValidator<T> {\n constructor(attrs?: ValidatorAttributes) {\n super({ message: 'must be less than or equal to 0', ...attrs });\n }\n\n override validate(value: T): boolean {\n return (toFloat(String(value)) || 0) <= 0;\n }\n\n readonly name = 'NegativeOrZero';\n}\n\nexport class Positive<T> extends AbstractValidator<T> {\n constructor(attrs?: ValidatorAttributes) {\n super({ message: 'must be greater than 0', ...attrs });\n }\n\n override validate(value: T): boolean {\n const fv = toFloat(String(value));\n return isNaN(fv) || fv > 0;\n }\n\n readonly name = 'Positive';\n}\n\nexport class PositiveOrZero<T> extends AbstractValidator<T> {\n constructor(attrs?: ValidatorAttributes) {\n super({ message: 'must be greater than or equal to 0', ...attrs });\n }\n\n override validate(value: T): boolean {\n return (toFloat(String(value)) || 0) >= 0;\n }\n\n readonly name = 'PositiveOrZero';\n}\n\nfunction _min(attrs: SizeAttributes) {\n return attrs.min ?? 0;\n}\n\nfunction _max(attrs: SizeAttributes) {\n return attrs.max ?? Number.MAX_SAFE_INTEGER;\n}\n\nexport class Size extends AbstractValidator<string> {\n min: number;\n max: number;\n\n constructor(attrs: SizeAttributes = {}) {\n super({ message: `size must be between ${_min(attrs)} and ${_max(attrs)}`, ...attrs });\n this.min = _min(attrs);\n this.max = _max(attrs);\n if (this.min > 0) {\n this.impliesRequired = true;\n }\n }\n\n override validate(value: string | null | undefined): boolean {\n // JSR380 considers empty values valid, unless a positive `min` makes the\n // value required (see `impliesRequired` above). `Size` also applies to\n // arrays, which `isLength()` rejects, so length is checked here.\n if (value == null || (value as { length?: number }).length === 0) {\n return this.min <= 0;\n }\n // eslint-disable-next-line sort-keys\n return isLength(value, { min: this.min, max: this.max });\n }\n\n readonly name = 'Size';\n}\n\nexport class Digits<T> extends AbstractValidator<T> {\n integer: number;\n fraction: number;\n\n constructor(attrs: DigitAttributes) {\n super({\n message: `numeric value out of bounds (<${attrs.integer} digits>.<${attrs.fraction} digits> expected)`,\n ...attrs,\n });\n this.integer = attrs.integer;\n this.fraction = attrs.fraction;\n }\n\n override validate(value: T): boolean {\n return (\n String(Math.floor(Math.abs(toFloat(String(value))))).length <= this.integer &&\n // eslint-disable-next-line camelcase\n isDecimal(String(value), { decimal_digits: `0,${this.fraction}` })\n );\n }\n\n readonly name = 'Digits';\n}\n\nexport class Past<T> extends AbstractValidator<T> {\n constructor(attrs?: ValidatorAttributes) {\n super({ message: 'must be a past date', ...attrs });\n }\n\n override validate(value: T): boolean {\n return isBefore(String(value));\n }\n\n readonly name = 'Past';\n}\n\n/*\n @PastOrPresent has no client-side implementation yet.\n It would consider any input valid and let the server-side to do validation.\n (It's not trivial to ensure the same granularity of _present_ as on the server-side:\n year / month / day / minute).\n*/\n// export class PastOrPresent extends AbstractValidator<any> {\n// constructor(attrs?: ValidatorAttributes) {\n// super({ message: 'must be a date in the past or in the present', ...attrs });\n// }\n// validate() {\n// return true;\n// }\n// }\n\nexport class Future<T> extends AbstractValidator<T> {\n constructor(attrs?: ValidatorAttributes) {\n super({ message: 'must be a future date', ...attrs });\n }\n\n override validate(value: T): boolean {\n return isAfter(String(value));\n }\n\n readonly name = 'Future';\n}\n\n/*\n @FutureOrPresent has no client-side implementation yet.\n It would consider any input valid and let the server-side to do validation.\n (It's not trivial to ensure the same granularity of _present_ as on the server-side:\n year / month / day / minute).\n*/\n// export class FutureOrPresent extends AbstractValidator<any> {\n// constructor(attrs?: ValidatorAttributes) {\n// super({ message: 'must be a date in the present or in the future', ...attrs });\n// }\n// validate = () => true;\n// }\n\nfunction _regexp(attrs: PatternAttributes | RegExp | string) {\n if (typeof attrs === 'string') {\n return new RegExp(attrs, 'u');\n }\n\n if (attrs instanceof RegExp) {\n return attrs;\n }\n\n if (typeof attrs.regexp === 'string') {\n return new RegExp(attrs.regexp, 'u');\n }\n\n return attrs.regexp;\n}\n\nexport class Pattern extends AbstractValidator<string> {\n regexp: RegExp;\n\n constructor(attrs: PatternAttributes | RegExp | string) {\n super({\n message: `must match the following regular expression: ${_regexp(attrs).toString()}`,\n ..._asValidatorAttributes(attrs),\n });\n this.regexp = _regexp(attrs);\n }\n\n override validate(value: any): boolean {\n // JSR380: null values are considered valid\n return value == null || matches(value, this.regexp);\n }\n\n readonly name = 'Pattern';\n}\n\n/**\n * Validator that reports an error when the bound HTML element validation\n * returns false from `element.checkValidity()` and `element.validity.valid`.\n */\nexport class ValidityStateValidator<T> extends AbstractValidator<T> {\n override message = '';\n\n // eslint-disable-next-line no-useless-constructor,@typescript-eslint/no-useless-constructor\n constructor() {\n super();\n }\n\n override validate(): boolean {\n return false;\n }\n\n readonly name = 'ValidityStateValidator';\n}\n"]}
|
package/index.js
CHANGED
|
@@ -11,7 +11,7 @@ export * from './stringConverters.js';
|
|
|
11
11
|
vaadinObj.registrations ??= [];
|
|
12
12
|
vaadinObj.registrations.push({
|
|
13
13
|
is: feature ? `@vaadin/hilla-lit-form/${feature}` : '@vaadin/hilla-lit-form',
|
|
14
|
-
version: '25.
|
|
14
|
+
version: '25.4.0-alpha1',
|
|
15
15
|
});
|
|
16
16
|
})();
|
|
17
17
|
//# sourceMappingURL=index.js.map
|
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAE5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,uBAAuB,CAAC;AAItC,CAAC,CAAC,OAAO,EAAE,SAAS,GAAG,CAAC,UAAU,CAAC,MAAM,KAAK,EAAE,CAAC,EAAE,EAAE;IACnD,SAAS,CAAC,aAAa,KAAK,EAAE,CAAC;IAC/B,SAAS,CAAC,aAAa,CAAC,IAAI,CAAC;QAC3B,EAAE,EAAE,OAAO,CAAC,CAAC,CAAC,0BAA0B,OAAO,EAAE,CAAC,CAAC,CAAC,wBAAwB;QAC5E,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAE5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,uBAAuB,CAAC;AAItC,CAAC,CAAC,OAAO,EAAE,SAAS,GAAG,CAAC,UAAU,CAAC,MAAM,KAAK,EAAE,CAAC,EAAE,EAAE;IACnD,SAAS,CAAC,aAAa,KAAK,EAAE,CAAC;IAC/B,SAAS,CAAC,aAAa,CAAC,IAAI,CAAC;QAC3B,EAAE,EAAE,OAAO,CAAC,CAAC,CAAC,0BAA0B,OAAO,EAAE,CAAC,CAAC,CAAC,wBAAwB;QAC5E,OAAO,EAAE,eAAe;KACzB,CAAC,CAAC;AACL,CAAC,CAAC,EAAE,CAAC","sourcesContent":["export * from './Binder.js';\nexport * from './BinderRoot.js';\nexport * from './BinderNode.js';\nexport * from './Field.js';\nexport * from './Models.js';\nexport type * from './ProvisionalModel.js';\nexport * from './Validation.js';\nexport * from './Validators.js';\nexport * from './Validity.js';\nexport * from './stringConverters.js';\n\n// @ts-expect-error: esbuild injection\n// eslint-disable-next-line @typescript-eslint/no-unsafe-call\n((feature, vaadinObj = (globalThis.Vaadin ??= {})) => {\n vaadinObj.registrations ??= [];\n vaadinObj.registrations.push({\n is: feature ? `@vaadin/hilla-lit-form/${feature}` : '@vaadin/hilla-lit-form',\n version: '25.4.0-alpha1',\n });\n})();\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vaadin/hilla-lit-form",
|
|
3
|
-
"version": "25.
|
|
3
|
+
"version": "25.4.0-alpha1",
|
|
4
4
|
"description": "Hilla form utils",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"module": "index.js",
|
|
@@ -69,8 +69,8 @@
|
|
|
69
69
|
"access": "public"
|
|
70
70
|
},
|
|
71
71
|
"dependencies": {
|
|
72
|
-
"@vaadin/hilla-frontend": "25.
|
|
73
|
-
"@vaadin/hilla-models": "25.
|
|
72
|
+
"@vaadin/hilla-frontend": "25.4.0-alpha1",
|
|
73
|
+
"@vaadin/hilla-models": "25.4.0-alpha1",
|
|
74
74
|
"validator": "13.15.22"
|
|
75
75
|
},
|
|
76
76
|
"peerDependencies": {
|