Decorators in TypeScript are used to add metadata or modify the behavior of class members, such as properties and methods. They are declared using the @
symbol followed by the decorator's name. @GV Decorators can be applied to model properties. When a decorator is applied to a target, it is executed immediately during the target's definition, allowing you to perform custom actions or validations.
GV.maxLength(maxLength: number)
Description: Specifies the maximum allowed length for a string property.
Parameters:
maxLength
(number): The maximum length allowed for the string property.Usage:
typescriptCopy code
import { GV } from 'some-library';
class MyClass {
@GV.maxLength(50)
myStringProperty: string;
}
GV.minLength(minLength: number)
Description: Specifies the minimum required length for a string property.
Parameters:
minLength
(number): The minimum length required for the string property.Usage:
typescriptCopy code
import { GV } from 'some-library';
class MyClass {
@GV.minLength(5)
myStringProperty: string;
}
GV.required()
Description: Marks a property as mandatory, ensuring that it must have a value assigned when creating an instance of the class.
Usage: