@serenity-is/corelib / LengthValidationRule
Class: LengthValidationRule
Defined in: src/ui/helpers/builtinvalidationrules.ts:38
Requires the length of a text, or of a list, to be between a minimum and a maximum, the parameters being [min, max].
Extends
Constructors
Constructor
new LengthValidationRule():
LengthValidationRule
Returns
LengthValidationRule
Inherited from
Properties
defaultText
defaultText:
string="Please enter no more than {0} characters."
Defined in: src/ui/helpers/builtinvalidationrules.ts:41
The text of the message for when its key has no text, e.g. the English one.
Overrides
textKey
textKey:
string="Validation.MaxLength"
Defined in: src/ui/helpers/builtinvalidationrules.ts:40
The local text key of the message of the rule, which can have the parameters of the rule as {0}, {1}, used when
the attribute gives no message of its own.
Overrides
[typeInfo]
static[typeInfo]:ClassTypeInfo<"Serenity.">
Defined in: src/ui/helpers/builtinvalidationrules.ts:39
Overrides
Methods
check()
check(
value,params):boolean
Defined in: src/ui/helpers/builtinvalidationrules.ts:43
Checks a value by the rule. It is not called for an empty value, i.e. null, an empty string or an empty list, as being required is a rule of its own.
Parameters
value
any
The value, e.g. a number for a decimal editor, or a text.
params
[number, number]
The parameters of the rule, as the server sends them.
Returns
boolean
Whether the value is valid.
Overrides
getDefaultText()
getDefaultText(
params):string
Defined in: src/ui/helpers/builtinvalidationrules.ts:52
Gets the text of the message for when its key has no text, by default defaultText.
Parameters
params
[number, number]
The parameters of the rule.
Returns
string
Overrides
getMessageArgs()
getMessageArgs(
params):any[]
Defined in: src/ui/helpers/builtinvalidationrules.ts:57
Gets what the message has as {0}, {1} and so on, by default the parameters of the rule.
Parameters
params
[number, number]
The parameters of the rule.
Returns
any[]
Overrides
getTextKey()
getTextKey(
params):string
Defined in: src/ui/helpers/builtinvalidationrules.ts:48
Gets the local text key of the message, by default textKey, which a rule can choose by its parameters, e.g. a length rule by whether it has a minimum.
Parameters
params
[number, number]
The parameters of the rule.
Returns
string
Overrides
registerRule()
protectedstaticregisterRule<TypeName>(typeName):ClassTypeInfo<TypeName>
Defined in: src/base/validationrule.ts:75
Registers a rule class by its type key, e.g. this.registerRule("MyApp.") for MyApp.EvenValidationRule.
Type Parameters
TypeName
TypeName
Parameters
typeName
StringLiteral<TypeName>
The full name of the type, or its namespace ending with a dot.
Returns
ClassTypeInfo<TypeName>