11import { Component , inject , resource , signal } from '@angular/core' ;
2- import { apply , applyEach , applyWhen , debounce , disabled , email , Field , FieldTree , form , maxLength , min , minLength , pattern , required , schema , submit , validate , validateAsync , validateTree , ValidationError , WithField } from '@angular/forms/signals' ;
2+ import { apply , applyEach , applyWhen , debounce , disabled , email , Field , FieldTree , form , maxLength , metadata , min , minLength , pattern , required , schema , submit , validate , validateAsync , validateTree , ValidationError , WithField } from '@angular/forms/signals' ;
33
44import { BackButton } from '../back-button/back-button' ;
55import { DebugOutput } from '../debug-output/debug-output' ;
6- import { FormError } from '../form-error/form-error' ;
6+ import { FormFieldInfo } from '../form-field-info/form-field-info' ;
7+ import { FIELD_INFO } from '../form-props' ;
78import { GenderIdentity , IdentityForm , identitySchema , initialGenderIdentityState } from '../identity-form/identity-form' ;
89import { Multiselect } from '../multiselect/multiselect' ;
910import { RegistrationService } from '../registration-service' ;
@@ -60,6 +61,7 @@ export const formSchema = schema<RegisterFormData>((schemaPath) => {
6061 } ,
6162 onError : ( ) => undefined
6263 } ) ;
64+ metadata ( schemaPath . username , FIELD_INFO , ( ) => "A username must consists of 3-12 characters." )
6365
6466 // Age validation
6567 min ( schemaPath . age , 18 , { message : 'You must be >=18 years old.' } ) ;
@@ -81,6 +83,7 @@ export const formSchema = schema<RegisterFormData>((schemaPath) => {
8183 applyEach ( schemaPath . email , ( emailPath ) => {
8284 email ( emailPath , { message : 'E-Mail format is invalid' } ) ;
8385 } ) ;
86+ metadata ( schemaPath . email , FIELD_INFO , ( ) => "Please enter at least one valid E-Mail address" )
8487
8588 // Password validation
8689 required ( schemaPath . password . pw1 , { message : 'A password is required' } ) ;
@@ -104,6 +107,7 @@ export const formSchema = schema<RegisterFormData>((schemaPath) => {
104107 message : 'The entered password must match with the one specified in "Password" field' ,
105108 } ;
106109 } ) ;
110+ metadata ( schemaPath . password , FIELD_INFO , ( ) => "Please enter a password with min 8 characters and a special character." )
107111
108112 // Newsletter validation
109113 applyWhen (
@@ -130,7 +134,7 @@ export const formSchema = schema<RegisterFormData>((schemaPath) => {
130134
131135@Component ( {
132136 selector : 'app-registration-form-3' ,
133- imports : [ BackButton , Field , DebugOutput , FormError , IdentityForm , Multiselect ] ,
137+ imports : [ BackButton , Field , DebugOutput , FormFieldInfo , IdentityForm , Multiselect ] ,
134138 templateUrl : './registration-form-3.html' ,
135139 styleUrl : './registration-form-3.scss' ,
136140 // Also possible: set SignalFormsConfig only for local component:
0 commit comments