-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update CI file to publish Docs on master branch push.
Updated Package for Dart only projects. Updated Readme.
- Loading branch information
1 parent
ce07d83
commit 3c06051
Showing
20 changed files
with
226 additions
and
46 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,11 @@ | ||
## [v0.2.0] | ||
|
||
### Added | ||
- Support for all Dart projects. | ||
|
||
## [v0.1.0] | ||
|
||
Initial Release | ||
|
||
[v0.2.0]: https://github.com/flrx/validator/compare/v0.2.0...v0.1.0 | ||
[v0.1.0]: https://github.com/flrx/validator/tag/v0.1.0 |
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 |
---|---|---|
|
@@ -3,19 +3,17 @@ | |
# abort on errors | ||
set -e | ||
|
||
# build | ||
npm run docs:build | ||
|
||
# navigate into the build output directory | ||
cd .vuepress/dist | ||
|
||
# if you are deploying to a custom domain | ||
# echo 'www.example.com' > CNAME | ||
|
||
git config --global user.email "[email protected]" | ||
git config --global user.name "Cirrus CI: Flrx Validator" | ||
git init | ||
git add -A | ||
git commit -m 'deploy' | ||
|
||
git push -f [email protected]:flrx/validator.git master:gh-pages | ||
git remote add origin https://$DEPLOYMENT_TOKEN@github.com/flrx/validator.git | ||
git push -f -u origin master:gh-pages | ||
|
||
cd - |
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 |
---|---|---|
@@ -1,16 +1,176 @@ | ||
# example | ||
# Validator Examples | ||
|
||
A new Flutter project. | ||
## Using FormField | ||
|
||
## Getting Started | ||
### example/lib/material_form.dart | ||
|
||
This project is a starting point for a Flutter application. | ||
```dart | ||
import 'package:flrx_validator/rules/email_rule.dart'; | ||
import 'package:flrx_validator/rules/required_rule.dart'; | ||
import 'package:flrx_validator/validator.dart'; | ||
import 'package:flutter/material.dart'; | ||
A few resources to get you started if this is your first Flutter project: | ||
class MaterialForm extends StatefulWidget { | ||
MaterialForm({Key key}) : super(key: key); | ||
- [Lab: Write your first Flutter app](https://flutter.dev/docs/get-started/codelab) | ||
- [Cookbook: Useful Flutter samples](https://flutter.dev/docs/cookbook) | ||
@override | ||
_MaterialFormState createState() => _MaterialFormState(); | ||
} | ||
For help getting started with Flutter, view our | ||
[online documentation](https://flutter.dev/docs), which offers tutorials, | ||
samples, guidance on mobile development, and a full API reference. | ||
class _MaterialFormState extends State<MaterialForm> { | ||
final _formKey = GlobalKey<FormState>(); | ||
@override | ||
Widget build(BuildContext context) { | ||
return Scaffold( | ||
appBar: AppBar(title: Text('Material Form Validator')), | ||
body: SingleChildScrollView( | ||
padding: const EdgeInsets.all(16), | ||
child: Form( | ||
key: _formKey, | ||
child: Column( | ||
crossAxisAlignment: CrossAxisAlignment.start, | ||
children: <Widget>[ | ||
TextFormField( | ||
validator: | ||
Validator().add(RequiredRule()).add(EmailRule()).build(), | ||
decoration: InputDecoration(hintText: 'Email'), | ||
), | ||
buildDropdown(), | ||
Padding( | ||
padding: const EdgeInsets.symmetric(vertical: 16.0), | ||
child: RaisedButton( | ||
onPressed: onFormSubmitPressed, | ||
child: Text('Submit'), | ||
), | ||
), | ||
], | ||
), | ||
), | ||
), | ||
); | ||
} | ||
Widget buildDropdown() { | ||
return DropdownButtonFormField<String>( | ||
validator: Validator().add(RequiredRule()).build(), | ||
value: "", | ||
items: <DropdownMenuItem<String>>[ | ||
DropdownMenuItem<String>( | ||
child: Text('Please select an Item'), | ||
value: "", | ||
), | ||
DropdownMenuItem<String>( | ||
child: Text('Item 1'), | ||
value: "Item 1", | ||
) | ||
], | ||
); | ||
} | ||
void onFormSubmitPressed() { | ||
if (_formKey.currentState.validate()) { | ||
// Process data. | ||
} | ||
} | ||
} | ||
``` | ||
|
||
## Using TextEditingController | ||
|
||
### example/lib/cupertino_form.dart | ||
|
||
```dart | ||
import 'package:flrx_validator/rules/email_rule.dart'; | ||
import 'package:flrx_validator/rules/required_rule.dart'; | ||
import 'package:flrx_validator/validator.dart'; | ||
import 'package:flutter/cupertino.dart'; | ||
class CupertinoForm extends StatefulWidget { | ||
@override | ||
_CupertinoFormState createState() => _CupertinoFormState(); | ||
} | ||
class _CupertinoFormState extends State<CupertinoForm> { | ||
TextEditingController _textEditingController = TextEditingController(); | ||
String emailValidationMessage = ""; | ||
@override | ||
Widget build(BuildContext context) { | ||
return DefaultTextStyle( | ||
style: const TextStyle( | ||
fontFamily: '.SF UI Text', | ||
inherit: false, | ||
fontSize: 17.0, | ||
color: CupertinoColors.black, | ||
), | ||
child: CupertinoPageScaffold( | ||
navigationBar: CupertinoNavigationBar( | ||
previousPageTitle: "Form Selection", | ||
middle: Text('Cupertino Form Validation'), | ||
), | ||
child: CupertinoScrollbar( | ||
child: SingleChildScrollView( | ||
padding: | ||
const EdgeInsets.symmetric(vertical: 32.0, horizontal: 16.0), | ||
child: Column( | ||
crossAxisAlignment: CrossAxisAlignment.start, | ||
children: <Widget>[ | ||
SizedBox(height: 72), | ||
CupertinoTextField( | ||
controller: _textEditingController, | ||
prefixMode: OverlayVisibilityMode.always, | ||
placeholder: 'Email', | ||
prefix: Icon( | ||
CupertinoIcons.mail_solid, | ||
color: CupertinoColors.lightBackgroundGray, | ||
size: 28.0, | ||
), | ||
decoration: BoxDecoration( | ||
border: Border( | ||
bottom: BorderSide( | ||
width: 0.0, color: CupertinoColors.inactiveGray)), | ||
), | ||
padding: | ||
EdgeInsets.symmetric(horizontal: 6.0, vertical: 12.0), | ||
clearButtonMode: OverlayVisibilityMode.editing, | ||
), | ||
Padding( | ||
padding: const EdgeInsets.fromLTRB(34, 8, 16, 16), | ||
child: Text( | ||
emailValidationMessage, | ||
style: TextStyle( | ||
color: CupertinoColors.destructiveRed, | ||
fontSize: 12, | ||
), | ||
), | ||
), | ||
Center( | ||
child: CupertinoButton.filled( | ||
child: Text('Submit'), onPressed: onFormSubmitPressed), | ||
) | ||
], | ||
), | ||
), | ||
)), | ||
); | ||
} | ||
@override | ||
void dispose() { | ||
_textEditingController.dispose(); | ||
super.dispose(); | ||
} | ||
void onFormSubmitPressed() { | ||
String value = _textEditingController.text; | ||
setState(() { | ||
emailValidationMessage = Validator<String>() | ||
.add(RequiredRule()) | ||
.add(EmailRule()) | ||
.validate(value) ?? | ||
''; | ||
}); | ||
} | ||
} | ||
``` |
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 |
---|---|---|
@@ -1,6 +1,7 @@ | ||
name: flrx_validator | ||
description: Validator on steroids | ||
version: 0.1.0 | ||
description: > | ||
A powerful, extensible validator package to get validation messages based on a list of rules. | ||
version: 0.2.0 | ||
author: Flrx Team <[email protected]> | ||
homepage: https://flrx.github.io/validator/ | ||
|
||
|
@@ -9,10 +10,7 @@ environment: | |
|
||
dependencies: | ||
meta: ^1.1.6 | ||
flutter: | ||
sdk: flutter | ||
|
||
dev_dependencies: | ||
flutter_test: | ||
sdk: flutter | ||
test_api: ^0.2.5 | ||
test: ^1.6.5 | ||
test_coverage: ^0.3.0+1 |
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
Oops, something went wrong.