Skip to content

Commit 326b293

Browse files
committed
docs(tutorial): part2/4/5 튜토리얼 본문을 framework helper 패턴으로 통일 (영/한)
직전 sed 부작용 정정. 옛 사용자 정의 static class 호출(Domain.X(args) 또는 DomainErrors.X(args))을 모두 framework helper 패턴(DomainError.For<T>(new XKind(), value, msg))으로 본문 재작성. 대상: - part2-validation-patterns/01..05 (영/한) - part4-practical-guide/03-cqrs-integration, 04-testing-strategies (영/한) - part5-domain-examples/03-user-management-domain/UserManagementDomain (영/한) - part5-domain-examples/04-scheduling-domain/{root,SchedulingDomain} (영/한) - part1-valueobject-concepts/12-type-safe-enums (영/한) 각 라인의 짝이 되는 .cs 파일에서 실제 사용 패턴(TypeName, ErrorKind, 메시지) 을 확인 후 1:1 매핑. 컴파일 가능한 코드로 통일. 검증: \bDomain\.[A-Z]+\( 같은 컴파일 불가 패턴 0건. 후속(별도 커밋): 13/14 학습 흐름 자체가 옛 사용자 정의 패턴 도입·진화이므로 본문 재구성 필요. 30+ 라인 영향, 큰 작업.
1 parent 96349b7 commit 326b293

22 files changed

Lines changed: 74 additions & 74 deletions

File tree

  • Docs.Site/src/content/docs
    • ko/tutorials/functional-valueobject
      • part1-valueobject-concepts/12-type-safe-enums
      • part2-validation-patterns
      • part4-practical-guide
      • part5-domain-examples
    • tutorials/functional-valueobject
      • part1-valueobject-concepts/12-type-safe-enums
      • part2-validation-patterns
      • part4-practical-guide
      • part5-domain-examples

Docs.Site/src/content/docs/ko/tutorials/functional-valueobject/part1-valueobject-concepts/12-type-safe-enums/index.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -266,17 +266,17 @@ public sealed class Currency : SmartEnum<Currency, string>
266266
public static Validation<Error, string> Validate(string currencyCode) =>
267267
!string.IsNullOrWhiteSpace(currencyCode)
268268
? ValidateThreeLetters(currencyCode)
269-
: DomainErrors.Empty(currencyCode);
269+
: DomainError.For<Currency>(new DomainErrorKind.Empty(), currencyCode, "Currency code is empty");
270270

271271
private static Validation<Error, string> ValidateThreeLetters(string currencyCode) =>
272272
currencyCode.Length == 3 && currencyCode.All(char.IsLetter)
273273
? ValidateSupported(currencyCode)
274-
: DomainErrors.NotThreeLetters(currencyCode);
274+
: DomainError.For<Currency>(new DomainErrorKind.WrongLength(), currencyCode, "Currency code must be exactly 3 letters");
275275

276276
private static Validation<Error, string> ValidateSupported(string currencyCode) =>
277277
GetAllSupportedCurrencies().Any(c => c.GetCode() == currencyCode)
278278
? currencyCode
279-
: DomainErrors.Unsupported(currencyCode);
279+
: DomainError.For<Currency>(new Unsupported(), currencyCode, "Currency is not supported");
280280
}
281281
```
282282

@@ -349,7 +349,7 @@ public sealed class PriceRange : ComparableValueObject
349349
Price minPrice, Price maxPrice) =>
350350
(decimal)minPrice.Amount <= (decimal)maxPrice.Amount
351351
? (minPrice, maxPrice)
352-
: DomainErrors.MinExceedsMax(minPrice, maxPrice);
352+
: DomainError.For<PriceRange>(new MinExceedsMax(), $"{minPrice}/{maxPrice}", "Minimum price exceeds maximum");
353353

354354
protected override IEnumerable<IComparable> GetComparableEqualityComponents()
355355
{

Docs.Site/src/content/docs/ko/tutorials/functional-valueobject/part2-validation-patterns/01-bind-sequential-validation/index.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ private static Validation<Error, string> ValidateCountryAndPostalCodeMatch(strin
6666
("KR", var code) when code.Length == 5 && code.All(char.IsDigit) => country,
6767
("US", var code) when code.Length == 5 && code.All(char.IsDigit) => country,
6868
("JP", var code) when code.Length == 7 && code.All(char.IsDigit) => country,
69-
_ => Domain.CountryPostalCodeMismatch(country, postalCode)
69+
_ => DomainError.For<Address>(new CountryPostalCodeMismatch(), $"{country}/{postalCode}", "Country and postal code mismatch")
7070
};
7171
```
7272

@@ -142,7 +142,7 @@ public sealed class Address : ValueObject
142142
("KR", var code) when code.Length == 5 && code.All(char.IsDigit) => country,
143143
("US", var code) when code.Length == 5 && code.All(char.IsDigit) => country,
144144
("JP", var code) when code.Length == 7 && code.All(char.IsDigit) => country,
145-
_ => Domain.CountryPostalCodeMismatch(country, postalCode)
145+
_ => DomainError.For<Address>(new CountryPostalCodeMismatch(), $"{country}/{postalCode}", "Country and postal code mismatch")
146146
};
147147
}
148148
```

Docs.Site/src/content/docs/ko/tutorials/functional-valueobject/part2-validation-patterns/02-apply-parallel-validation/index.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,12 +201,12 @@ public sealed class UserRegistration : ValueObject
201201
private static Validation<Error, string> ValidateEmailFormat(string email) =>
202202
!string.IsNullOrWhiteSpace(email) && email.Contains("@") && email.Contains(".")
203203
? email
204-
: Domain.EmailMissingAt(email);
204+
: DomainError.For<UserRegistration>(new EmailMissingAt(), email, "Email is missing @ sign");
205205

206206
private static Validation<Error, string> ValidatePasswordStrength(string password) =>
207207
password.Length >= 8
208208
? password
209-
: Domain.PasswordTooShort(password);
209+
: DomainError.For<UserRegistration>(new PasswordTooShort(), password, "Password is too short");
210210
}
211211
```
212212

Docs.Site/src/content/docs/ko/tutorials/functional-valueobject/part2-validation-patterns/03-apply-bind-combined-validation/index.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ private static Validation<Error, decimal> ValidateFinalAmount(string orderAmount
6969
decimal.TryParse(discountInput, out var discount) &&
7070
discount >= 0 && discount <= orderAmount
7171
? orderAmount - discount
72-
: Domain.DiscountAmountExceedsOrder(orderAmountInput, discountInput);
72+
: DomainError.For<OrderInfo>(new DiscountAmountExceedsOrder(), $"{orderAmountInput}:{discountInput}", "Discount amount exceeds order amount");
7373
```
7474

7575
## 실전 지침
@@ -145,7 +145,7 @@ public sealed class OrderInfo : ValueObject
145145
decimal.TryParse(discountInput, out var discount) &&
146146
discount >= 0 && discount <= orderAmount
147147
? orderAmount - discount
148-
: Domain.DiscountAmountExceedsOrder(orderAmountInput, discountInput);
148+
: DomainError.For<OrderInfo>(new DiscountAmountExceedsOrder(), $"{orderAmountInput}:{discountInput}", "Discount amount exceeds order amount");
149149
}
150150
```
151151

Docs.Site/src/content/docs/ko/tutorials/functional-valueobject/part2-validation-patterns/04-apply-internal-bind-validation/index.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,12 +156,12 @@ public sealed class MemberRegistration : ValueObject
156156
private static Validation<Error, string> ValidateUsernameFormat(string username) =>
157157
!string.IsNullOrWhiteSpace(username) && username.Length >= 3
158158
? username
159-
: Domain.UsernameTooShort(username);
159+
: DomainError.For<MemberRegistration>(new UsernameTooShort(), username, "Username is too short");
160160

161161
private static Validation<Error, string> ValidateUsernameAvailability(string username) =>
162162
!username.StartsWith("admin")
163163
? username
164-
: Domain.UsernameNotAvailable(username);
164+
: DomainError.For<MemberRegistration>(new UsernameNotAvailable(), username, "Username is not available");
165165
}
166166
```
167167

Docs.Site/src/content/docs/ko/tutorials/functional-valueobject/part2-validation-patterns/05-bind-internal-apply-validation/index.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -61,23 +61,23 @@ public static Validation<Error, (string CountryCode, string AreaCode, string Loc
6161
private static Validation<Error, string> ValidatePhoneNumberFormat(string phoneNumber) =>
6262
!string.IsNullOrWhiteSpace(phoneNumber) && phoneNumber.Length >= 10
6363
? phoneNumber
64-
: Domain.PhoneNumberTooShort(phoneNumber);
64+
: DomainError.For<PhoneNumber>(new DomainErrorKind.TooShort(), phoneNumber, "Phone number is too short");
6565

6666
// 구성 요소 병렬 검증 - Apply 내부에서 병렬 실행
6767
private static Validation<Error, string> ValidateCountryCode(string phoneNumber) =>
6868
phoneNumber.StartsWith("+82") || phoneNumber.StartsWith("+1")
6969
? phoneNumber.Substring(0, 3)
70-
: Domain.CountryCodeUnsupported(phoneNumber);
70+
: DomainError.For<PhoneNumber>(new CountryCodeUnsupported(), phoneNumber, "Country code is not supported");
7171

7272
private static Validation<Error, string> ValidateAreaCode(string phoneNumber) =>
7373
phoneNumber.Length >= 6 && phoneNumber.Substring(3, 3).All(char.IsDigit)
7474
? phoneNumber.Substring(3, 3)
75-
: Domain.AreaCodeInvalid(phoneNumber);
75+
: DomainError.For<PhoneNumber>(new DomainErrorKind.InvalidFormat(), phoneNumber, "Area code is invalid");
7676

7777
private static Validation<Error, string> ValidateLocalNumber(string phoneNumber) =>
7878
phoneNumber.Length >= 10 && phoneNumber.Substring(6).All(char.IsDigit)
7979
? phoneNumber.Substring(6)
80-
: Domain.LocalNumberInvalid(phoneNumber);
80+
: DomainError.For<PhoneNumber>(new DomainErrorKind.InvalidFormat(), phoneNumber, "Local number is invalid");
8181
```
8282

8383
## 실전 지침
@@ -154,23 +154,23 @@ public sealed class PhoneNumber : ValueObject
154154
private static Validation<Error, string> ValidatePhoneNumberFormat(string phoneNumber) =>
155155
!string.IsNullOrWhiteSpace(phoneNumber) && phoneNumber.Length >= 10
156156
? phoneNumber
157-
: Domain.PhoneNumberTooShort(phoneNumber);
157+
: DomainError.For<PhoneNumber>(new DomainErrorKind.TooShort(), phoneNumber, "Phone number is too short");
158158

159159
// 구성 요소 병렬 검증 - Apply 내부에서 병렬 실행
160160
private static Validation<Error, string> ValidateCountryCode(string phoneNumber) =>
161161
phoneNumber.StartsWith("+82") || phoneNumber.StartsWith("+1")
162162
? phoneNumber.Substring(0, 3)
163-
: Domain.CountryCodeUnsupported(phoneNumber);
163+
: DomainError.For<PhoneNumber>(new CountryCodeUnsupported(), phoneNumber, "Country code is not supported");
164164

165165
private static Validation<Error, string> ValidateAreaCode(string phoneNumber) =>
166166
phoneNumber.Length >= 6 && phoneNumber.Substring(3, 3).All(char.IsDigit)
167167
? phoneNumber.Substring(3, 3)
168-
: Domain.AreaCodeInvalid(phoneNumber);
168+
: DomainError.For<PhoneNumber>(new DomainErrorKind.InvalidFormat(), phoneNumber, "Area code is invalid");
169169

170170
private static Validation<Error, string> ValidateLocalNumber(string phoneNumber) =>
171171
phoneNumber.Length >= 10 && phoneNumber.Substring(6).All(char.IsDigit)
172172
? phoneNumber.Substring(6)
173-
: Domain.LocalNumberInvalid(phoneNumber);
173+
: DomainError.For<PhoneNumber>(new DomainErrorKind.InvalidFormat(), phoneNumber, "Local number is invalid");
174174
}
175175
```
176176

Docs.Site/src/content/docs/ko/tutorials/functional-valueobject/part4-practical-guide/03-cqrs-integration/index.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -245,9 +245,9 @@ public sealed class Email : IEquatable<Email>
245245
public static Fin<Email> Create(string? value)
246246
{
247247
if (string.IsNullOrWhiteSpace(value))
248-
return Domain.Empty(value ?? "null");
248+
return DomainError.For<Email>(new DomainErrorKind.Empty(), value ?? "null", "Email is empty");
249249
if (!value.Contains('@'))
250-
return Domain.InvalidFormat(value);
250+
return DomainError.For<Email>(new DomainErrorKind.InvalidFormat(), value, "Email format is invalid");
251251
return new Email(value.ToLowerInvariant());
252252
}
253253

Docs.Site/src/content/docs/ko/tutorials/functional-valueobject/part4-practical-guide/04-testing-strategies/index.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -293,9 +293,9 @@ public sealed class Email : IEquatable<Email>
293293
public static Fin<Email> Create(string? value)
294294
{
295295
if (string.IsNullOrWhiteSpace(value))
296-
return Domain.Empty(value ?? "null");
296+
return DomainError.For<Email>(new DomainErrorKind.Empty(), value ?? "null", "Email is empty");
297297
if (!value.Contains('@'))
298-
return Domain.InvalidFormat(value);
298+
return DomainError.For<Email>(new DomainErrorKind.InvalidFormat(), value, "Email format is invalid");
299299
return new Email(value.ToLowerInvariant());
300300
}
301301

Docs.Site/src/content/docs/ko/tutorials/functional-valueobject/part5-domain-examples/03-user-management-domain/UserManagementDomain/index.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -68,15 +68,15 @@ dotnet run
6868
public static Fin<Email> Create(string? value)
6969
{
7070
if (string.IsNullOrWhiteSpace(value))
71-
return Domain.Empty;
71+
return DomainError.For<Email>(new DomainErrorKind.Empty(), value ?? "", "Email is empty");
7272

7373
var normalized = value.Trim().ToLowerInvariant();
7474

7575
if (normalized.Length > 254)
76-
return Domain.TooLong;
76+
return DomainError.For<Email, int>(new DomainErrorKind.TooLong(), normalized.Length, "Email exceeds maximum length");
7777

7878
if (!Pattern.IsMatch(normalized))
79-
return Domain.InvalidFormat;
79+
return DomainError.For<Email>(new DomainErrorKind.InvalidFormat(), value, "Email format is invalid");
8080

8181
return new Email(normalized);
8282
}
@@ -105,7 +105,7 @@ public static Fin<Password> Create(string? plainText)
105105
.Count(x => x);
106106

107107
if (score < 3)
108-
return Domain.WeakPassword;
108+
return DomainError.For<Password, int>(new InsufficientComplexity(), score, "Password is too weak");
109109

110110
return new Password(HashPassword(plainText));
111111
}
@@ -125,7 +125,7 @@ public static Fin<Password> Create(string? plainText)
125125
public static Fin<PhoneNumber> Create(string? value, string defaultCountryCode = "82")
126126
{
127127
if (string.IsNullOrWhiteSpace(value))
128-
return Domain.Empty;
128+
return DomainError.For<PhoneNumber>(new DomainErrorKind.Empty(), value ?? "", "Phone number is empty");
129129

130130
var digits = new string(value.Where(char.IsDigit).ToArray());
131131

@@ -134,7 +134,7 @@ public static Fin<PhoneNumber> Create(string? value, string defaultCountryCode =
134134
digits = digits[1..];
135135

136136
if (digits.Length < 9 || digits.Length > 11)
137-
return Domain.InvalidFormat;
137+
return DomainError.For<PhoneNumber>(new DomainErrorKind.WrongLength(), value, "Phone number length is invalid");
138138

139139
return new PhoneNumber(defaultCountryCode, digits);
140140
}
@@ -161,7 +161,7 @@ public static Fin<Username> Create(string? value)
161161
{
162162
// ...
163163
if (ReservedNames.Contains(normalized))
164-
return Domain.Reserved(normalized);
164+
return DomainError.For<Username>(new ReservedName(), normalized, "Username is reserved");
165165

166166
return new Username(normalized);
167167
}

Docs.Site/src/content/docs/ko/tutorials/functional-valueobject/part5-domain-examples/04-scheduling-domain/SchedulingDomain/index.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ public sealed class DateRange : IEquatable<DateRange>
8181
public static Fin<DateRange> Create(DateOnly start, DateOnly end)
8282
{
8383
if (end < start)
84-
return Domain.EndBeforeStart;
84+
return DomainError.For<DateRange>(new EndBeforeStart(), $"{start}~{end}", "End is before start");
8585
return new DateRange(start, end);
8686
}
8787

@@ -131,9 +131,9 @@ public sealed class Duration : IComparable<Duration>
131131
public static Fin<Duration> FromMinutes(int minutes)
132132
{
133133
if (minutes < 0)
134-
return Domain.NegativeDuration;
134+
return DomainError.For<Duration, int>(new DomainErrorKind.Negative(), minutes, "Duration is negative");
135135
if (minutes > 525600) // 1년
136-
return Domain.ExceedsMaximum;
136+
return DomainError.For<Duration, int>(new DomainErrorKind.AboveMaximum(), minutes, "Duration exceeds maximum");
137137
return new Duration(minutes);
138138
}
139139

@@ -161,7 +161,7 @@ public sealed class RecurrenceRule : IEquatable<RecurrenceRule>
161161
public static Fin<RecurrenceRule> Weekly(params DayOfWeek[] days)
162162
{
163163
if (days.Length == 0)
164-
return Domain.NoDaysSpecified;
164+
return DomainError.For<RecurrenceRule, int>(new DomainErrorKind.Empty(), 0, "No days specified");
165165
return new RecurrenceRule(RecurrenceType.Weekly, days, null, 1);
166166
}
167167

@@ -179,7 +179,7 @@ public sealed class RecurrenceRule : IEquatable<RecurrenceRule>
179179
public static Fin<DateRange> Create(DateOnly start, DateOnly end)
180180
{
181181
if (end < start)
182-
return Domain.EndBeforeStart;
182+
return DomainError.For<DateRange>(new EndBeforeStart(), $"{start}~{end}", "End is before start");
183183
return new DateRange(start, end);
184184
}
185185
```

0 commit comments

Comments
 (0)