-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
693c01d
commit ad0110e
Showing
19 changed files
with
774 additions
and
119 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { Form, Input } from 'antd'; | ||
import { Rule, RuleObject } from 'antd/es/form'; | ||
import { Address } from 'ton-core'; | ||
|
||
interface Props { | ||
name?: string; | ||
placeholder?: string; | ||
className?: string; | ||
rules?: Rule[]; | ||
} | ||
|
||
const AddressInput = ({ | ||
name = 'address', | ||
placeholder = 'EQDPK...0nYxC', | ||
className = '', | ||
rules = [], | ||
}: Props) => { | ||
const fieldRules = [ | ||
...rules, | ||
() => ({ | ||
validator(_rule: RuleObject, value: string) { | ||
if (!value) return Promise.resolve(); | ||
try { | ||
Address.parse(value); | ||
} catch { | ||
return Promise.reject('Invalid Address'); | ||
} | ||
|
||
return Promise.resolve(); | ||
}, | ||
}), | ||
]; | ||
return ( | ||
<Form.Item name={name} rules={fieldRules} className={className}> | ||
<Input placeholder={placeholder} /> | ||
</Form.Item> | ||
); | ||
}; | ||
|
||
export default AddressInput; |
Oops, something went wrong.