# From String type to Email type

**URL:** <https://forums.fsharp.org/t/from-string-type-to-email-type/1450>\
**Category:** General\
**Tags:** beginners\
**Created:** [September 13, 2020, 4:37pm UTC](https://forums.fsharp.org/t/from-string-type-to-email-type/1450 "2020-09-13T16:37:09Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![goraci](https://yyz2.discourse-cdn.com/flex030/user_avatar/forums.fsharp.org/goraci/32/803_2.png) [@goraci](https://forums.fsharp.org/u/goraci)\
**Post date:** [September 13, 2020, 4:37pm UTC](https://forums.fsharp.org/t/from-string-type-to-email-type/1450/1 "2020-09-13T16:37:09Z")

</div>

Hello  
I am researching String type. The question is - can i make special types from string type in F# ? Can it accomplished in F# or any other langs. Example. I am modelling domain with types and i have User type ( typescript).

```
type User = {
  name: string;
  age: number;
  email: Email;
  password: Password
}

```

type Email = /some pattern here/  
I want Email type here because i need some shape of the string. So any string too general for this. So the shape is.

- It must have only 2 special chars . and @.
- It must have only a-z chars and length of it not more then 100 chars.  
Can i accomplish this in F# ? I can not do this in typescript for example.  
I read about refinement type it’s pretty close to that i need.

---

<div class="post-metadata">

**Author:** ![FoggyFinder](https://yyz2.discourse-cdn.com/flex030/user_avatar/forums.fsharp.org/foggyfinder/32/136_2.png) [@FoggyFinder](https://forums.fsharp.org/u/FoggyFinder)\
**Post date:** [September 13, 2020, 5:18pm UTC](https://forums.fsharp.org/t/from-string-type-to-email-type/1450/2 "2020-09-13T17:18:10Z")

</div>

Take a look at [Designing with types: Constrained strings](https://fsharpforfunandprofit.com/posts/designing-with-types-more-semantic-types/) article.
